uimenu

Creates a menu bar for a figure.

Syntax

h = uimenu('label', menulabel)

h = uimenu('label', menulabel, property, value, ...)

h = uimenu(parent, 'label', menulabel, property, value, ...)

Inputs

menulabel
Text displayed for h.
Type: string
parent
Handle of a figure.
Type: double | integer
property, value
'enable'
Specifies if h is enabled.
Valid values are 'on' (default) and 'off'.
Type: string
'tag'
User-defined string to tag graphical control objects.
Type: string
'userdata'
User-defined numerical data.
Type: complex | mtx | scalar

Outputs

h
Handle of the uimenu created. The 'position' of h is in the order it is created. Once h has been created, its 'position' or 'label' on the menu bar cannot be changed.
Type: scalar

Example

Creates a menu bar for a figure:
%Callback
function outfunc1 = func1(h,callstate)
  warndlg('Some modal warning')
end

% Callback
function outfunc2 = func2(h,callstate,argument1,argument2)
  disp('Menu item 2 callback')
end

f = figure;

% Test 1 Creating menu for a figure
m1 = uimenu('label', 'Menu1');
m2 = uimenu('label', 'Menu2', 'parent', f);

% Create menu items for each menu created
item1_m1 = uimenuitem('parent', m1, 'label', 'Foo1', 'callback', '@func1');
item1_m2 = uimenuitem(m2, 'label', 'A very long menu description', 'callback', {@func2, 'foo', 1});