Specifications

4 Programming GUIs
4-10
Managing GUI Data with the Handles Structure
GUIDE provides a mechanism for storing and retrieving global data using the
same structure that contains the GUI component handles. The
handles
structure, which containing the handles of all the components in the GUI, is
passed to each callback in the application M-file. Therefore, this structure is
useful for saving any global data. The following example illustrates this
technique.
If you are not familiar with MATLAB structures, see Structures for more
information.
Passing Data in the Handles Structure
This example demonstrates how to use the handles structure to pass data
between callbacks.
Suppose you want to create a GUI containing a slider and an editable text box
that behaves as follows:
When users moves the slider, the text box displays the slider’s current value.
When users types a value into the text box, the slider updates to this value.
If they enter an out-of-range value in the text box, the application returns a
message indicating how many erroneous values have been entered.
This picture shows the GUI with a static text field above the edit text box.