Creating Graphical User Interfaces Previous page   Next Page

The Tag Property

The Tag property provides a string as a unique identifier for each component. GUIDE uses this identifier to construct unique callback names for the different components in the GUI.

When you first add a component to a layout, GUIDE sets the value of Tag to a default string such as pushbutton1. If the component has a Callback property, GUIDE also sets the value of Callback to the string %automatic. The following figure shows an example.

GUI showing push buttons and selection menu-

When you save or run the GUI, GUIDE generates an M-file that includes stubs for the Callback functions for each component that has one. GUIDE creates a unique function name for each Callback function in the M-file by prefixing the value of the Tag property to the string _Callback, for example, pushbutton1_Callback. GUIDE also changes the value of the Callback property to a string that is a calling sequence for the callback. For example, if the name of the GUI M-file is simple_gui, the new value of the Callback property becomes

You can redefine the value of Tag to be more descriptive, but the value of each Tag property must be unique for a given GUI. In this example, change the Tag property of the pop-up menu to plot_pop-up before you save or run the GUI for the first time. The following figure shows the new Tag value.

Using the property inspector to change the tag to plot_popup

When you save or run the GUI, GUIDE sets the name of the callback subfunction in the pop-up menu Callback property to plot_pop-up_Callback. If you later change the Tag, GUIDE updates the Callback property to match the new Tag -- see Changing a Tag.

Similarly, change the push button tags to surf_pushbutton, mesh_pushbutton, and contour_pushbutton.

To learn more, see Setting Component Properties -- The Property Inspector.


Previous page  Callback Properties Programming the GUI Next page

© 1994-2005 The MathWorks, Inc.