argument is the name of the callback function. The last three arguments are provided by
MATLAB, and are discussed in the section, “GUIDE Callback Syntax” on page 7-5.
NoteGUIDE does not automatically generate callback functions for other UI
components, such as tables, panels, or button groups. If you want any of these
components to execute a callback function, then you must create the callback by right-
clicking on the component in the layout, and selecting an item under View Callbacks in
the context menu.
GUIDE Callback Syntax
All callbacks must accept at least three input arguments:
- hObject — The UI component that triggered the callback.
- eventdata — A variable that contains detailed information about specific mouse or
keyboard actions. - handles — A struct that contains all the objects in the UI. GUIDE uses the guidata
function to store and maintain this structure.
For the callback function to accept additional arguments, you must put the additional
arguments at the end of the argument list in the function definition.
The eventdata Argument
The eventdata argument provides detailed information to certain callback functions. For
example, if the end user triggers the KeyPressFcn, then MATLAB provides information
regarding the specific key (or combination of keys) that the end user pressed. If
eventdata is not available to the callback function, then MATLAB passes it as an empty
array. The following table lists the callbacks and components that use eventdata.
Callback Property Name Component
WindowKeyPressFcn
WindowKeyReleaseFcn
WindowScrollWheel
figure
KeyPressFcn figure, uicontrol, uitable
KeyReleaseFcn figure, uicontrol, uitable
SelectionChangedFcn uibuttongroup
Write Callbacks in GUIDE