How to make a modal window generated during openingFcn on top of the GUIDE window

2 views (last 30 days)
I have a logic to check something when a GUIDE window opens (in openingFcn) and if the check fails, display a warning modal window (warndlg). The GUIDE window is also a modal window. The problem is that since the openingFcn is called before the GUIDE window shows up and as a result the warning modal window shows up first, it will be behind the GUIDE window. A user has to move the GUIDE window around or close the GUIDE window to see the warning message, which defeats the purpose of a warning. Is there a callback for events such as window_opened in Matlab?

Accepted Answer

Greg
Greg on 19 Jun 2018
Edited: Greg on 19 Jun 2018
Use uiwait.
h = warndlg(. . .);
uiwait(h);
%%%These commands won't execute until warndlg is closed
%%%I.e., your GUIDE figure won't show up to block the warning
Using uiwait comes with other problems ( all of MATLAB is blocked until the warndlg is closed). I won't preach App Designer vs. GUIDE, but App Designer has solved these kinds of limitations with options such as uialert and uiconfirm.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!