Creating Graphical User Interfaces Previous page   Next Page

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.

menu editor with cursor pointing to the new menu  button

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.

menu editor showing file properties

Adding Items to a Menu

Use the New Menu Item tool to define the menu items that are displayed in the drop-down menu.

menu editor with cursor pointing to new menu item

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.

menu editor with entries in the label and tag fields

You can also

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.

menu editor used to create a cascading menu

Laying Out Three Menus

The following Menu Editor illustration shows three menus defined for the figure menu bar.

menu editor showing three menu types

When you run the GUI, the menu titles appear in the menu bar.

GUI with menu titles shown in menu bar


Previous page  Creating Menus -- The Menu Editor Menu Callbacks Next page

© 1994-2005 The MathWorks, Inc.