MATLAB Creating Graphical User Interfaces

(ff) #1
Callback Property Name Component
CellEditCallback
CellSelectionCallback

uitable

Renaming and Removing GUIDE-Generated Callbacks


Renaming Callbacks

GUIDE creates the name of a callback function by combining the component’s Tag
property and the callback property name. If you change the component’s Tag value, then
GUIDE changes the callback's name the next time you save the UI.

If you decide to change the Tag value after saving the UI, then GUIDE updates the
following items (assuming that all components have unique Tag values).


  • Component's callback function definition

  • Component’s callback property value

  • References in the code file to the corresponding field in the handles structure


To rename a callback function without changing the component’s Tag property:

(^1) Change the name in the callback function definition.
(^2) Update the component’s callback property by changing the first argument passed to
the anonymous function. For example, the original callback property for a push
button might look like this:
@(hObject,eventdata)myui('pushbutton1_Callback',...
hObject,eventdata,guidata(hObject))
In this example, you must change, 'pushbutton1_Callback' to the new function
name.
3 Change all other references to the old function name to the new function name in the
code file.
Deleting Callbacks
You can delete a callback function when you want to remove or change the function that
executes when the end user performs a specific action. To delete a callback function:
7 Programming a GUIDE App

Free download pdf