Livecode Wiki
Advertisement

Used with the decorations property to specify that a window displays a menu bar. When used as the style property of a button, specifies that the contents of the button is displayed as a menu. Also used to designate a menu by name or number.Syntax:

menu

Examples:

disable menu "Text"
set the decorations of stack "Help" to "menu,maximize"

Use the menu keyword to give a window a menu bar (on Unix and Windows systems).

If a button's style is set to "menu", its menuMode property determines how the menu is displayed when the user clicks the button.

You can use the menu keyword to refer to one of the buttons in the current menu bar. For example, if the first menu in the menu bar is called "File", the expression the name of menu 1 evaluates to "button " File"".

Remember that in LiveCode, menus are usually implemented as buttons: the button's style and menuMode properties control how it is displayed, and the button's text property is used as the list of menu items.

The syntax for menu item strings is:

[[[flags]]] [[label]] ['/' [[accelerator]] ['|' [[tag]]]]


Where flags may include:

  • !c, !n, !`: the menu item has respectively, a check, no check, or a selected radio button
  • (: the menu item is disabled
  • -: the menu item is replaced with a menu separator
  • multiple tab characters: the number of tabs specifies the depth of the menu item; use this to create submenus

The accelerator can be specified as one of:

  • char: Command key + specified char
  • keyname: Named key without modifiers
  • modifiers char: Specified modifiers + character
  • modifiers keyname: Specified modifiers + named key


In the accelerator, modifiers is either:

  • a space separated list of: 'command' or 'cmd', 'control' or 'ctrl', 'option' or 'opt', 'alt', 'shift'; in this case the keyname/char

should be separated from the list by a space

  • a sequence of characters, including:
    • ^: Command
    • @: Shift
    • #: Option
    • %: Control

In this case no space between the sequence and keyname/char is required

The following named keys are supported:

  • F1, F2, F3, F4, ... F15,
  • Left, Up, Right, Down,
  • Backspace, Delete,
  • Tab, Space,
  • Return, Enter,
  • Home, End, Escape,
  • PgUp, PgDown,
  • Insert (not on Mac OS X)


On Mac OS X, these keys will be replaced with the appropriate system standard glyph.

A tag can be specified as a `|` character followed by a string of ASCII characters. If such a tag is present then that tag will take the place of the menu label as the parameter to the menuPick.

A tag will only be recognised following the accelerator. To specify a menu tag without an accelerator shortcut, an empty accelerator can be specified using `/|` followed by the tag text.

Note: As Windows and Linux do not have the 'Command' modifier, on those platforms 'Command' is an synonym for 'Control'. To ensure cross-platform uniformity it is important that you use 'Command' in preference to 'Control' since 'Control' on Mac OS X is a less frequently used modifier.

Cross-platform note: The menu decoration has no effect on Mac OS and OS X systems. On Windows systems, the menu decoration must be set along with the maximize or minimize decorations:you cannot use maximize or minimize without including menu.

See also: menuPick (message), button (object), style (property), properties (property), menuMode (property), decorations (property),

Advertisement