Creating Graphical User Interfaces    

The Menu Callback

The menu callback executes when users select the menu item. You can type the MATLAB code to execute in the Menu Editor Callback text box. This approach is manageable if the callback is a very simple command (e.g., print -dps). However, it is generally better to add a subfunction to the application M-file, as GUIDE automatically does for uicontrol callbacks.

Specifying the Callback String

The application M-file enables you to call a subfuction as a callback for components in the GUI. To do this, you must use the appropriate syntax for the callback. For example, using the Select All menu item from the previous example gives the following callback string:

where:

After determining the correct callback string, type it into the Menu Editor Callback text box. Then add the subfunction called menu_Edit_SelectAll_Callback to the MyGui.m file.


 Defining Menus for the Menubar Defining Context Menus