MATLAB Function Reference    

Create menus on figure windows



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.


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.


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
Menu check indicator
Value: on, off
Default: off
Color of text
Value: ColorSpec
Default: [0 0 0]
Menu label
Value: string
Object highlighted when selected
Value: on, off
Default: on
Separator line mode
Value: on, off
Default: off
Uimenu visibility
Value: on, off
Default: on
General Information About the Object
Keyboard equivalent
Value: character
Handles of submenus
Value: vector of handles
Enable or disable the uimenu
Value: on, off
Default: on
Uimenu object's parent
Value: handle
User-specified object identifier
Value: string
Class of graphics object
Value: string (read-only)
Default: uimenu
User-specified data
Value: matrix
Controlling the Object Position
Relative uimenu position
Value: scalar
Default: [1]
Controlling Callback Routine Execution
Callback routine interruption
Value: cancel, queue
Default: queue
Button press callback routine
Value: string
Control action
Value: string
Callback routine executed during object creation
Value: string
Callback routine executed during object deletion
Value: string
Callback routine interruption mode
Value: on, off
Default: on
Controlling Access to Objects
Whether handle is accessible from command line and GUIs
Value: on, callback, off
Default: on
Whether selectable by mouse click
Value: on, off
Default: on


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.

Object Hierarchy

See Also

uicontrol, uicontextmenu, gcbo, set, get, figure

  uiimport Uimenu Properties