Creating Graphical User Interfaces | ![]() ![]() |
Changing Component Tag Properties
Guide automatically assigns a string to the uicontrol Tag
property and uses this string to:
tag
_Callback
)handles
structure containing the handle of the object (e.g., handles.
tag
).If you change the Tag
after GUIDE generates the callback subfunction, GUIDE does not generate a new subfunction. However, since the handles
structure is created at run-time, GUIDE uses the new Tag
to name the field that contains the objects handle.
Problems Caused by Changing Tags
Changing the Tag
can cause program errors when you have referenced an objects handle. For example, the following statement,
file_list = get(handles.listbox1,'String');
gets the value of the String
property from the list box whose Tag
is listbox1
. If you had changed the list box's Tag
to file_listbox
, subsequent instantiations of the GUI would require you to change the statement to:
file_list = get(handles.file_listbox,'String');
Avoiding Problems
The best approach is to set the Tag
property on components when you add them to the layout. If you do change a Tag
after generating the application M-file and want to rename callback subfunctions to maintain the consistent naming used by GUIDE, you should:
handles
structure.![]() | Renaming Application Files and Tags | Changing the Name of Callback Subfunctions | ![]() |