Creating Graphical User Interfaces |
Defining Menus for the Menu Bar
When you create a drop-down menu, MATLAB adds its title to the figure menu bar. You can then create menu items for that menu. Each menu item can have a cascading menu, also known as a submenu, and these items can have cascading menus, and so on.
Creating a Menu
The first step is to click the New Menu tool to create a drop-down menu.
Specifying Menu Properties
Click on the menu title, Untitled 1 in the picture above, to display fields that allow you to set the Label
, Tag
, Accelerator
, Separator
, Checked
, and Enable
menu properties as well as specify the Callback
string. GUIDE applies any property changes immediately. Click More options to display the Property Inspector where you can edit all the properties for the selected item.
The View button displays the callback subfunction in an editor. See Menu Callbacks for more information.
Adding Items to a Menu
Use the New Menu Item tool to define the menu items that are displayed in the drop-down menu.
For example, to add an Open menu item under File
, select File
then click the New Menu Item tool.
Fill in the Label and Tag fields for the new menu item.
To create additional drop-down menus, use the New Menu tool in the same way you did to create the File
menu. For example, the following picture also shows an Edit
drop-down menu.
To create a cascading menu, select the menu item that will be the title for the cascading menu, then click the New Menu Item tool. In the example below, select Copy
then click the New Menu Item tool.
Laying Out Three Menus
The following Menu Editor illustration shows three menus defined for the figure menu bar.
When you run the GUI, the menu titles appear in the menu bar.
Creating Menus -- The Menu Editor | Menu Callbacks |
© 1994-2005 The MathWorks, Inc.