Specifications
2 MATLAB GUIs
2-20
Waiting for User Input
The GUIDE application option,
Function does not return until application window dismissed
generates an application M-file that is designed to wait for user input. It does
this by calling
uiwait, which blocks further execution of the M-file.
While execution waits, MATLAB processes the event queue. This means that
any user-interactions with the GUI (such as clicking a push button) can invoke
callback routines, but the execution stream always returns to the application
M-file until one of two events occurs:
•The GUI figure is deleted.
•A callback for an object in the GUI figure executes a
uiresume command.
This feature provides a way to block the MATLAB command line until the user
responds to the dialog box, but at the same time, allows callback routines to
execute. When used in conjunction with a modal dialog, you can restrict user
interaction to the dialog.
See Launching a Dialog to Confirm an Operation for an example that uses this
option.
Code in the Application M-File
GUIDE implements this feature by generating code in the application M-file
that uses the
uiwait command
% Wait for callbacks to run and window to be dismissed:
uiwait(fig);
where fig is the handle of the GUI figure.
Note Ensure that you have only one occurrence of uiwait in your application
M-file, including in commented lines.