Specifications
2 MATLAB GUIs
2-16
The arguments are listed in the following table.
For example, if you create a layout having a push button whose
Tag property is
set to
pushbutton1, then GUIDE generates this subfunction header in the
application M-file.
function varargout = pushbutton1_Callback(h,eventdata,handles,varargin)
Assigning the Callback Property String
When you first add a component to your GUI layout, its Callback property is
set to the string
<automatic>. This string signals GUIDE to replace it with one
that calls the appropriate callback subfunction in the application M-file when
you save or activate the GUI. For example, GUIDE sets the
Callback property
for
pushbutton1 uicontrol to
my_gui('pushbutton1_Callback',gcbo,[],guidata(gcbo))
where:
•
my_gui – is the name of the application M-file.
•
pushbutton1_Callback – is the name of the callback routine subfunction
defined in
my_gui.
•
gcbo – is a command that returns the name of the callback object (i.e.,
pushbutton1).
•
[] – is a place holder for the currently unused eventdata argument.
•
guidata(gcbo) – returns the handles structure.
Callback Function Arguments
h
The handle of the object whose callback is executing.
eventdata
Empty, reserved for future use.
handles
A structure containing the handles of all components in the
GUI whose fieldnames are defined by the object’s
Tag
property. Can also be used to pass data to other callback
functions or the main program.
varargin
A variable-length list of arguments that you want to pass to
the callback function.