MATLAB Creating Graphical User Interfaces

(ff) #1
% Delete the dialog box
delete(app)
end

(^2) Open the main app into Code View, right-click the app.UIFigure object in the
Component Browser, and select Callbacks > Add CloseRequestFcn callback.
Then add code that deletes both apps.
function MainAppCloseRequest(app,event)
% Delete both apps
delete(app.DialogApp)
delete(app)
end
Example: Plotting App That Opens a Dialog Box
This app consists of a main plotting app that has a button for selecting options in a dialog
box. The Options button calls the dialog box app with input arguments. In the dialog box,
the callback for the OK button sends the user's selections back to the main app by calling
a public function in the main app.
17 App Programming

Free download pdf