Navigation

Operators and Keywords

Function List:

C++ API

: hui = uimenu (property, value, …)
: hui = uimenu (h, property, value, …)

Create a uimenu object and return a handle to it.

If h is omitted then a top-level menu for the current figure is created. If h is given then a submenu relative to h is created.

uimenu objects have the following specific properties:

"accelerator"

A string containing the key combination together with CTRL to execute this menu entry (e.g., "x" for CTRL+x).

"callback"

Is the function called when this menu entry is executed. It can be either a function string (e.g., "myfun"), a function handle (e.g., @myfun) or a cell array containing the function handle and arguments for the callback function (e.g., {@myfun, arg1, arg2}).

"checked"

Can be set "on" or "off". Sets a mark at this menu entry.

"enable"

Can be set "on" or "off". If disabled the menu entry cannot be selected and it is grayed out.

"foregroundcolor"

A color value setting the text color for this menu entry.

"label"

A string containing the label for this menu entry. A "&"-symbol can be used to mark the "accelerator" character (e.g., "E&xit")

"position"

An scalar value containing the relative menu position. The entry with the lowest value is at the first position starting from left or top.

"separator"

Can be set "on" or "off". If enabled it draws a separator line above the current position. It is ignored for top level entries.

Examples:

f = uimenu ("label", "&File", "accelerator", "f");
e = uimenu ("label", "&Edit", "accelerator", "e");
uimenu (f, "label", "Close", "accelerator", "q", ...
           "callback", "close (gcf)");
uimenu (e, "label", "Toggle &Grid", "accelerator", "g", ...
           "callback", "grid (gca)");

See also: figure.

Demonstration 1

The following code

 clf;
 surfl (peaks);
 colormap (copper (64));
 shading ('interp');
 f = uimenu ('label', '&File', 'accelerator', 'f');
 e = uimenu ('label', '&Edit', 'accelerator', 'e');
 uimenu (f, 'label', 'Close', 'accelerator', 'q', 'callback', 'close (gcf)');
 uimenu (e, 'label', 'Toggle &Grid', 'accelerator', 'g', 'callback', 'grid (gca)');

Produces the following figure

Figure 1

Package: octave