User`s guide

Customizing Callbacks in GUIDE
Customizing Callbacks in GUIDE
In this section...
“GUIDE Callback Templates” on page 8-15
“Callback Names and Signatures in GUIDE” on page 8-16
“GUIDE Callback Arguments” on page 8-20
“Changing Callbacks Assigned by GUIDE” on page 8-22
GUIDE Callback Templates
GUIDE defines conventions for callback syntax and arguments and
implements these conventions in the callback templates it adds to the GUI
code. Each template is like this one for the
Callback subfunction for a push
button.
% --- Executes on button press in pushbutton1.
function pushbutto n1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCB O)
% eventdata reserved - to be defined in a future v ersion of MATLAB
% handles structure with handles and user data (see GUIDATA)
...
The first comment line describes the event that triggers execution of the
callback. This is followed by the function definition line. The remaining
comments d escribe the input arguments. Insert your code after the last
comment.
Certain figure and GUI component callbacks provide event-specific data in
the
eventdata argument. As an example, this is the template for a push
button
KeyPressFcn callback.
% --- Executes on key pr ess with focus on pushbutton1
function pushbutto n1_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCB O)
% eventdata structure with the following fields (see UICONTROL)
% Key: n ame of the key that was pressed, in lower case
% Character: character interpretat ion of the key(s) that was pressed
8-15