Why should i not use msgbox in App Designer?

Why should i not use msgbox in App Designer?
The site is saying:
If you are using App Designer or creating apps with the uifigure function, then use uialert instead. For more information, see Migrating GUIDE Apps to App Designer.
msgbox is a tool that i know and it works fine for me. Why should i not use it?
thanks!

 Accepted Answer

uialert() was designed to work will app designer and has several nice features. For example,
  • the first input to uialert is the handle to your app figure (app.UIFigure) so that the alert appears on top of the app no matter where its postion is on the screen.
  • The default 'modal' value for uialert is 'true' which means your app is disabled until the user interacts with the alert. For msgbox, the default create-mode is non-modal which means the msgbox will not prevent further user interaction.
  • There's also some nice built-in icons available with uialert and its general aesthetic matches app designer better than msgbox.
  • uialert has an optional close request callback function that you can define and it executes when the alert window is closed.

5 Comments

Hello Adam,
thanks for you help.
As far as i can tell from your answer. There are some nice features to uialert(), which could be a reason to use it.
But i still see no reason NOT to use msgbox.
Or am i missing something here?
As far as I've tested it (r2019a), msgbox() is functional with apps built in app designer. Who knows if that will change in the future but currently it's not a problem.
To add to Adam list, msgbox is a java based window, while uialert, being part of an app, is not (I believe it is html based). So app based controls can work in environment where there's no java (e.g. web app server) whereas msgbox may fail there. And if matlab ever drops java (the licensing of java has become complicated recently) then msgbox may not longer be supported.
As of R2019a, as Adam says, you can still use msgbox if you wish. If you're concerned about portability or longevity, you may be better off with uialert (which looks nicer anyway in my opinion)
Alright. Thanks for your help guys!
i try msgbox() on R2021a and still works, thanks

Sign in to comment.

More Answers (0)

Categories

Find more on Update figure-Based Apps in Help Center and File Exchange

Products

Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!