uimenu - Create menus on figure windows

Syntax

handle = uimenu('PropertyName',PropertyValue,...)
handle = uimenu(parent,'PropertyName',PropertyValue,...)

Description

uimenu creates a hierarchy of menus and submenus that are displayed in the figure window's menu bar. You also use uimenu to create menu items for context menus.

handle = uimenu('PropertyName',PropertyValue,...) creates a menu in the current figure's menu bar using the values of the specified properties and assigns the menu handle to handle.

See the Uimenu Properties reference page for more information.

handle = uimenu(parent,'PropertyName',PropertyValue,...) creates a submenu of a parent menu or a menu item on a context menu specified by parent and assigns the menu handle to handle. If parent refers to a figure instead of another uimenu object or a uicontextmenu, MATLAB creates a new menu on the referenced figure's menu bar.

Remarks

MATLAB adds the new menu to the existing menu bar. If the figure does not have a menu bar, MATLAB creates one. Each menu choice can itself be a menu that displays its submenu when selected. uimenu accepts property name/property value pairs, as well as structures and cell arrays of properties as input arguments.

The uimenu Callback property defines the action taken when you activate the created menu item.

Uimenus only appear in figures whose Window Style is normal. If a figure containing uimenu children is changed to modal, the uimenu children still exist and are contained in the Children list of the figure, but are not displayed until the WindowStyle is changed to normal.

The value of the figure MenuBar property affects the content of the figure menu bar. When MenuBar is figure, a set of built-in menus precedes any user-created uimenus on the menu bar (MATLAB controls the built-in menus and their handles are not available to the user). When MenuBar is none, uimenus are the only items on the menu bar (that is, the built-in menus do not appear).

You can set and query property values after creating the menu using set and get.

Examples

This example creates a menu labeled Workspace whose choices allow users to create a new figure window, save workspace variables, and exit out of MATLAB. In addition, it defines an accelerator key for the Quit option.

f = uimenu('Label','Workspace');
    uimenu(f,'Label','New Figure','Callback','figure');
    uimenu(f,'Label','Save','Callback','save');
    uimenu(f,'Label','Quit','Callback','exit',... 
           'Separator','on','Accelerator','Q');

See Also

uicontrol, uicontextmenu, gcbo, set, get, figure

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS