MATLAB Function Reference Previous page   Next Page
uimenu

Create menus on figure windows

Syntax

Description

uimenu creates a hierarchy of menus and submenus that are displayed in the figure window's menu bar. You can 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.

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. 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 menu item. uimenu optionally returns the handle to the created uimenu object.

Uimenus only appear in figures whose WindowStyle is normal. If a figure containing uimenu children is changed to WindowStyle 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 location of the uimenu on the figure menu bar. When MenuBar is figure, a set of built-in menus precedes the 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.

Properties

This table lists all properties useful to uimenu objects, grouping them by function. Each property name acts as a link to a description of the property.

Property Name
Property Description
Property Value
Controlling Style and Appearance
Checked
Menu check indicator
Value: on, off
Default: off
ForegroundColor
Color of text
Value: ColorSpec
Default: [0 0 0]
Label
Menu label
Value: string
Separator
Separator line mode
Value: on, off
Default: off
Visible
Uimenu visibility
Value: on, off
Default: on
General Information About the Object
Accelerator
Keyboard equivalent
Value: character
Children
Handles of submenus
Value: vector of handles
Enable
Enable or disable the uimenu
Value: on, off
Default: on
Parent
Uimenu object's parent
Value: handle
Tag
User-specified object identifier
Value: string
Type
Class of graphics object
Value: string (read-only)
Default: uimenu
UserData
User-specified data
Value: matrix
Controlling the Object Position
Position
Relative uimenu position
Value: scalar
Default: [1]
Controlling Callback Routine Execution
BusyAction
Callback routine interruption
Value: cancel, queue
Default: queue
Callback
Control action
Value: string
CreateFcn
Callback routine executed during object creation
Value: string
DeleteFcn
Callback routine executed during object deletion
Value: string
Interruptible
Callback routine interruption mode
Value: on, off
Default: on
Controlling Access to Objects
HandleVisibility
Whether handle is accessible from command line and GUIs
Value: on, callback, off
Default: on

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.

See Also

uicontrol, uicontextmenu, gcbo, set, get, figure


Previous page  uiimport Uimenu Properties Next page

© 1994-2005 The MathWorks, Inc.