Specifications

3 Laying Out GUIs and Setting Properties
3-30
Generate Callback Function Prototypes
When you select Generate callback function prototypes in the GUI Options
dialog, GUIDE adds the most commonly used subfunctions to the GUI M-file
for any component you add to the GUI. You must then write the code for the
callback in this subfunction.
GUIDE also adds a subfunction whenever you edit a callback routine from the
Layout Editor’s right-click context menu and when you add menus to the GUI
using the Menu Editor.
Naming Callback Subfunctions
When you add a component to your GUI layout, GUIDE assigns a value to its
Tag property, which is then used to generate the name of the callback.
For example, the first push button you add to the layout is tagged
pushbutton1.
When generating the M-file, GUIDE adds a callback subfunction called
pushbutton1_Callback. If you define a ButtonDownFcn for the same push
button, GUIDE names its subfunction
pushbutton1_ButtonDownFcn.
Callback Function Syntax
The callback function syntax is of the form
function objectTag_Callback(hObject, eventdata, handles)
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 the following subfunction header
in the GUI M-file.
Argument Description
hObject
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 command line.