
9 Managing Application-Defined Data
9-4
2 Use the following command to save the data.
guidata(hObject,handles)
where hObject is the handle of the component for which the callback was
triggered. It is passed automatically to every callback.
Changing GUI Data in an M-File Generated by GUIDE
In a GUIDE-generated M-file, GUI data is always represented by the handles
structure. This example updates the
handles structure and then saves it.
1 Assume that the handles structure contains an application-defined field
handles.when whose value is 'now'.
2 In a GUI callback, make the desired change to the handles structure. This
example changes the value of
handles.when to 'later', but does not save
the
handles structure.
handles.when = 'later';
3 Save the changed version of the handles structure with the command
guidata(hObject,handles)
where hObject, which is passed automatically to every callback, is the
handle of the component for which the callback was triggered. If you do not
save the
handles structure, the change you made to it in the preceding step
is lost.
Application Data
Application data provides a way for applications to save and retrieve data
associated with a specified object. For a GUI, this is usually the GUI figure but
can also be any component. The data is stored as name/value pairs. Application
data enables you to create what are essentially user-defined properties for an
object.
Comentários a estes Manuais