Specifications

4 Programming GUIs
4-6
For example, if the GUI contains a push button whose String property is
'Yes', add the following code to its callback to make the GUI return 'Yes'
when the user presses the push button:
handles.output = 'Yes';
guidata(hObject, handles);
uiresume;
See the section “Managing GUI Data with the Handles Structure” on page 4-26
for more information about passing data with the
handles structure.
When the GUI is called with the command
OUT = my_gui
and a user presses the Yes push button, the GUI returns the output
OUT = 'Yes' to the command line.
The output
varargout, which is a cell array, can contain any number of output
arguments. By default, GUIDE creates just one output argument,
handles.output. To create a second output argument, add the command
varargout{2} = handles.second_output;
to the output function. You can set the value of handles.second_output in any
callback and then save it with the
guidata command.
If you want, you can choose more descriptive names than
output or
second_output for the fields of the handles structure corresponding to the
output arguments.
Callbacks
When a user activates a component of the GUI, the GUI executes the
corresponding callback. The name of the callback is determined by the
component’s
Tag property and the type of callback. For example, a push button
with the
Tag print_button executes the callback
function print_button_Callback(hObject, eventdata, handles)