Specifications
Example: Using the Modal Dialog to Confirm an Operation
4-43
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
9 After these comments, add the following code:
% Get the current position of the GUI from the handles structure
% to pass to the modal dialog.
pos_size = get(handles.figure1,'Position');
% Call modaldlg with the argument 'Position'.
user_response = modaldlg('Title','Confirm Close');
switch user_response
case {'No'}
% take no action
case 'Yes'
% Prepare to close GUI application window
% .
% .
% .
delete(handles.figure1)
end
Running the GUI with the Close Button
Run the GUI with the Close button by clicking the Run button on the Layout
Editor toolbar. The GUI appears as in the following figure:
When you click the
Close button on the GUI, the modal dialog appears as
shown in the following figure: