Creating Graphical User Interfaces | ![]() ![]() |
Implementing the GUI
This section describes the steps followed to implement the requirements described in the previous section.
Launching the Dialog
The Close button's callback needs to launch a dialog that asks for confirmation of the impending close operation. This callback must then wait for a dialog to return a value. To accomplish this, the dialog's application M-file assigns an output argument and the Close button's callback waits for it to be returned.
The following picture illustrates the dialog positioned over the GUI figure.
Wait for User Input
To make the dialog wait for user input, select Function does not return until application window dismissed in the GUIDE Application Options dialog. This option adds a call to uiwait in the dialog's application M-file.
Making the Dialog Figure Modal
To make the dialog figure modal, select the figure in the Layout Editor and then right-click to display the context menu. Select Property Inspector from the context menu. Use the Property Inspector to set the figure's WindowStyle
property to modal
.
Sequence Following a Close Button Press
The following sequence occurs when the user presses the Close button on the GUI application figure:
Yes
push button, the No
push button, or the close box (X
) on the window border. All other interactions with MATLAB are blocked.
![]() | Launching a Dialog to Confirm an Operation | The Close Button Callback | ![]() |