| Creating Graphical User Interfaces | ![]() |
Automatic Naming of Callback Routines
GUIDE automatically names the callback subfunctions it adds to the application M-file. It also sets the value of the Callback property to a string that causes this subfunction to execute when users activate the control.
Naming Callback Subfunctions
When you add a component to your GUI layout, GUIDE assigns a value to its Tag property that is then used to generate the name of the callback.
For example, the first push button you add to the layout is called pushbutton1. GUIDE adds a callback subfunction to the application M-file called pushbutton1_Callback when you save or activate the figure. If you define a ButtonDownFcn for the same push button, its subfunction is called pushbutton1_ButtonDownFcn.
Assigning the Callback String
When you first add a component to your GUI layout, its Callback property is set to the string <automatic>. This string signals GUIDE to replace it with one that calls the appropriate callback subfunction in the application M-file when you save or activate the GUI. For example, GUIDE sets the Callback property for pushbutton1 uicontrol to
my_gui('pushbutton1_Callback',gcbo,[],guidata(gcbo))
my_gui - is the name of the application M-file.pushbutton1_Callback - is the name of the callback routine subfunction defined in my_gui.gcbo - is a command that returns the name of the callback object (i.e., pushbutton1).[] - is a place holder for the currently unused eventdata argument.guidata(gcbo) - returns the handles structure.See Callback Function Syntax for more information on callback function arguments and Renaming Application Files and Tags for more information on how to change the names used by GUIDE.
| Understanding the Application M-File | Execution Paths in the Application M-File | ![]() |