Specifications

5 Application Examples
5-12
3 Once the user makes a choice, the confirmation dialog callbacks resume
execution and return a value to the
Close button callback.
4 Close button callback resumes execution and takes appropriate action
based on user response to the confirmation dialog.
The Close Button Callback
The Close button callback performs the following tasks:
Determines where to locate of the confirmation dialog based on the current
size and location of the GUI application figure.
Calls the M-file (
modaldlg) that launches the confirmation dialog with an
input argument that specifies where to locate the dialog and an output
argument to return the user response to the
Close button callback.
Takes the appropriate action depending on the answer returned from the
dialog.
Here is the
Close button callback:
function varargout = pushbutton1_Callback(h, eventdata, handles, varargin)
pos_size = get(handles.figure1,'Position');
dlg_pos = [pos_size(1)+pos_size(3)/5 pos_size(2)+pos_size(4)/5];
user_response = modaldlg(dlg_pos);
switch user_response
case {'no','cancel'}
return
case 'yes'
% Prepare to close GUI application figure
% .
% .
% .
delete(handles.figure1)
end
The Confirmation Dialog M-file
The confirmation dialog has its own M-file, which the main application calls to
launch the dialog. This M-file can be called in three ways:
No arguments – launch the dialog and wait for user input.