Specifications
Creating Menus — The Menu Editor
3-63
Menu Callbacks
By default, the Callback text field in the Menu Editor is set to the string
%automatic. This causes GUIDE to add the empty callback subfunction to the
GUI M-file when you save or run the GUI. If you change this string before
saving the GUI, GUIDE does not add a subfunction for that menu item.
Note that if you click the
View button before saving the GUI, GUIDE asks you
to save the GUI. It then runs the GUI, adds the appropriate callback
subfunctions to the M-file, and opens the M-file for editing.
Functions Generated in the GUI M-file
The Menu Editor generates an empty callback subfunction for every menu
item. Because clicking on a menu title automatically displays the menu below
it, you may not need to program callbacks at the title level. However, the
callback associated with a menu title can be a good place to enable or disable
menu items below it.
Consider the example from the previous section, as illustrated in the following
picture.
When a user selects the
to file item under the Edit menu Copy item, only the
to file callback is required to perform the action.
Suppose, however, that only certain objects can be copied to a file. You can use
the
Copy item callback to enable or disable the to file item, depending on the
type of object selected.