For a fully coded example of a StartupFcn callback, see Plotting App That Opens a
Dialog Box on page 17-16.
(^2) Call the dialog box app from within a callback in the main app. Open the main app
into Code View and add a callback function for the Options button. This callback
disables the Options button to prevent users from opening multiple dialog boxes.
Next, it gets the values to pass to the dialog box, and then it calls the dialog box app
with input arguments and an output argument. The output argument is the dialog box
app object.
function OptionsButtonPushed(app,event)
% Disable Plot Options button while dialog is open
app.OptionsButton.Enable = 'off';
% Get szvalue and cvalue
% ....
% Call dialog box with input values
app.DialogApp = DialogAppExample(app,szvalue,cvalue);
end
(^3) Define a property in the main app to store the dialog box app. Keeping the main app
open, create a private property called DialogApp. Select Property > Private
Property in the Editor tab. Then, change the property name in the properties
block to DialogApp.
properties (Access = private)
DialogApp % Dialog box app
end
Return Information to the Main App
Perform these steps to return the user's selections to the main app.
(^1) Create a public function in the main app that updates the UI. Open the main app into
Code View and select Function > Public Function in the Editor tab.
Change the default function name to the desired name, and add input arguments for
each option you want to pass from the dialog box to the main app. The app argument
must be first, so specify the additional arguments after that argument. Then add code
to the function that processes the inputs and updates the main app.
function updateplot(app,sz,c)
% Process sz and c
17 App Programming