Creating Graphical User Interfaces Previous page   Next Page

Callback Conventions in GUIDE

GUIDE defines conventions for callback syntax and arguments. These conventions enable GUIDE to provide commonly used information to each callback automatically.

Syntax and Arguments

The GUIDE template for a component callback is similar to this one for a uicontrol of style pushbutton.

The first comment line describes the event that triggers execution of the callback. Other comments describe the input arguments.

The template also includes the function definition. Insert your code after the last comment.

Function Definition.   GUIDE creates the callback name by appending an underscore (_) and the name of the callback property to the component's Tag property. In the example above, pushbutton1 is the Tag property for the push button, and Callback is one of the push button's callback properties. See Associating Callbacks with Components for more information.

Input Arguments.   All callbacks in the GUI M-file have the following input arguments:

The Handles Structure.   For a GUI that contains an edit text, a uipanel, a pop-up menu, and a push button, the handles structure that GUIDE creates originally looks similar to this. GUIDE uses a component's Tag property to name the structure element for its handle.

GUIDE stores and maintains the handles structure. If you change any of these variables, or make explicit changes to the handles structure, you must save the handles structure before exiting the callback. To do this, you must use the command

See Managing GUI Data with the Handles Structure and the guidata reference page for general information about the handles structure.

See Managing Application-Defined Data for information about using the handles structure.

Changing Callback Names Assigned by GUIDE

You can change callback names assigned by GUIDE in either of the following ways:

In either case, see Setting Component Properties -- The Property Inspector for information about using the Property Inspector to change property values.

Changing the Tag Property.   You can change a Tag property to give a component's callbacks a more meaningful name, e.g., you might change the Tag property from pushbutton1 to closebutton. If possible, change the Tag property before saving the GUI, then GUIDE automatically uses the new value when it names the callbacks. However, if you change the Tag property after saving the GUI, GUIDE updates the following items according to the new Tag, provided that all components have distinct tags:

Changing the Callback Property.   To rename a particular callback subfunction without changing the Tag property,


Previous page  Component and Figure Callbacks Callbacks in Programmatically Created GUIs Next page

© 1994-2005 The MathWorks, Inc.