User`s guide

8 Programming a GUIDE GUI
GUIDE Callback A
rguments
All callbacks in
a GUIDE-generated GUI code file have the following standard
input arguments
:
hObject —Handl
e of the object, e.g., the G UI component, for which the
callback was t
riggered. For a button group
SelectionChangeFcn callback,
hObject is the
handle of the s elected radio button o r toggle button.
eventdata —Se
quences of events triggered by user actions such as table
selections e
mitted by a component in the form of a MATLA B struct (or an
empty matrix
for components that do not generate eventdata)
handles —AM
ATLAB struct that contains the handles of all the objects
in the GUI, a
nd may also contain application-defined data. See “handles
Structure”
on page 8-22 for information about this structure.
Object Handle
The first a
rgument is the handle of the component issuing the callback. Use
it to obta
in relevant properties that the callback code uses and change them
as necess
ary. For example,
theText = get(hObject,'String');
places t
he
String property (which might be the contents of static text or name
of a but
ton) into the local variable
theText. You can change the property by
settin
g it, for example
set(hObject,'String',date)
This p
articular code changes the text of the object to display the current date.
Event Data
Even
t data is a stream of data describing user gestures, such as key presses,
scro
ll wheel movements, and mouse drags. The auto-generated callbacks of
GUI
DE GUIs can access event data for Handle Graphics
®
and u icontrol and
uit
able object callbacks. The following ones receive event data when triggered:
Cel
lEditCallback
in a uitable
Ce
llSelectionCallback
in a uitable
8-20