Panorama Live Menus are specified using a special language called LMSL (Live Menu Specification Language). Each line in this language controls a menu item, or an entire menu. Special characters in the line tell Panorama what style to use to display the menu item, how to attach submenus, what to do when a menu is chosen, and many more things.

Panorama includes a set of functions for easily generating LMSL text, including menu(, menuitem(, menuseparator(, arraymenuitems(, standardfilemenu(, standardeditmenu( and several more. There’s a function for anything you want to do to create a live menu, so for most users there is no reason to learn LMSL. However, it can be handy for advaced topics, and for debugging.

The basic component of LMSL is a line. Each line contains a complete description of a menu header or menu item. You can’t split the description of a single menu item over two or more lines, and you can’t pack descriptions of two or more menu items into a single line.

In LMSL, the first line is always the name of the entire menu, and you can include additional menus as well. The name must be surrounded with ( and ) characters, for example:

(Action)
(Color)
(Appointments)

Note: The actual menu titles will not contain the parentheses, so (Action) will create the Action menu.

If a line is not surrounded with ( and ) characters, it is a menu item. In its simplest form, each line simply contains the name of the item. Here is a menu named Color with three menu items.

(Color)
Red
Green
Blue

In most examples, though, the menu item contains a prefix and/or a suffix. These components are separated by a tab character (represented by ⇢ in the examples on this page).

prefix⇢title⇢suffix

The prefix controls whether or not the menu item is enabled, and whether or not the item is checked. The suffix controls the font, text size, style (italic, bold), color, indentation, key equivalent, action to perform, etc. The rest of this page will describe these suffixes and prefixes.

The prefix is optional, however, it’s a good idea to include it so that you don’t have to worry about special characters messing with your menu item title. For example, you might think that this line would create a menu item with a phone number:

(800) 555-1212

However, since a leading ( automatically disables the menu item (see below), this actually creates a disabled menu item of 800) 555-1212. To fix this, add a tab character (empty prefix) at the front.

⇢(800) 555-1212

Adding a prefix to all menu items is a good habit to get into, whether you intend to use a prefix option or not.

Each menu item must be include a specification of what action to take if the user selects this menu item. You can either specify one or more procedure statements, or you can specify an objective-C method that is in the responder chain. If you don’t know what the responder chain is, you’ll probably want to stick with procedure statements, which work by wrapping the code with curly braces { and } and sticking the whole thing into the menu item suffix. (Note: the code you enter between the { and } characters must not contain any carriage returns, it all has to be on one line.)

In this example, when the user selects the Hello menu item, a dialog with a “Hello World” greeting will appear.

⇢Hello⇢{message |Hello World|}

Oh wait - you’re an Objective-C programmer and you want to know about using methods in the responder chain? It’s simple really, simply enclose the method name in square brackets, like this:

⇢Print Setup...⇢[runPageSetup:] 

To find out what methods are available, look at the LMSL output of functions like standardfilemenu(, standardeditmenu(, etc.

Default Menu Action

If a menu item does not have a menu action it will be assigned a default menu action. If the menu is installed in the main menu bar (at the top of the screen), the default action is to call the .CustomMenu procedure in the current database. If the menu is a context menu (right click) the default is to invoke the ContextMenuAction statement. If the menu is associated with a pop-up menu button, the default action is to invoke the code associated with the button. If the menu is associated with a popup statement, the default action is to resume the procedure after the popup statement.

Disabling a Menu Item

To disable any menu item, insert a ( as the very first character of the line. For example, if the current invoice doesn’t contain a valid credit card, you might want to disable the option for charging the card.

(⇢Charge Credit Card

If the menu item action is an Objective-C method in the responder chain, it will automatically disable itself if appropriate, even if you don’t include a ( at the start. For example, a menu item that uses the [copy:] method will automatically disable itself if there is nothing to copy.

To include a separator item in a menu, simply make a menu item of (-, as shown below:

Red
Green
Blue
(-
Small
Medium
Large

To add a menu key equivalent to a menu item, add / followed by the key to the menu item suffix. This example assigns the command key equivalent Command-B to the Open Book menu item.

⇢Open Book⇢/B

You can add one or more modifier keys to the command key equivalent:

⇧ SHIFT
⌃ CONTROL
⌥ OPTION.

This example assigns the command key equivalent Command-Shift-Option-P to the Print Invoice menu item.

⇢Print Invoice⇢/⇧⌥P

Note: The best way to type these special characters is to copy them from this page and paste them into your code. (Or even better, use the menuitem( function to generate the LMSL for you.)

menuitem("Print Invoice","KEY","SHIFT-OPTION-P")

Alternate Menu Items

If the menu contains adjacent menu items that use the same command key equivalent with different modifier keys, you can specify that all but the first of these adjacent items are alternate menu items. Panorama will only display one of these menu items at a time – the others will be hidden until you press the appropriate modifier key. To specify that a menu is an alternate include the & character in front of the command key equivalent.

This example adds two alternate items to the menu. Normally when you click the menu, the Print menu item will appear. However, if you hold down the Option key, the Print menu item will change into “Print One Record”. (You can actually press and release the option key while holding down the mouse and see the menu change immediately.)

⇢Print⇢/P
⇢Print One Record⇢&/⌥P

Alternate menu items will only work if they are adjacent, and if all of them have the same key equivalent (in this case the letter P). If these conditions are not satisfied the menu items will not operate as alternates even if you include the & character.

LMSL has the ability to specify that an entire menu is a submenu of another menu item. In fact, menus can be nested, 2, 3, or more levels deep.

A menu must be defined before it can be used as a submenu. To define a menu as a submenu, use a suffix of *S after the menu name (don’t forget the tab character to separate the menu name from the suffix). This tells Panorama to define the menu, but not to include the menu in the main menu bar.

(Shippers)⇢*S
⇢Airborne
⇢Fedex
⇢US Postal Service
⇢UPS

Later in the menu definition you can attach this menu as a submenu to another menu item by including the menu name in parentheses in the suffix:

⇢Ship Via⇢(Shippers)

That’s all there is too it. When the menu is pulled down, Shippers will automatically appear as a submenu to the Ship Via menu item.

To specify that a menu item be bold or italic, add <B or <I to the suffix (or both):

⇢Bold Action⇢<B
⇢Slip Sideways⇢<I
⇢Super Important⇢<I<B

To specify a menu item color, insert # followed by a 6 digit hex representation of the color. This is identical to the way that colors are represented in HTML code.

This example displays the Launch menu item in green, the Abort menu item in red.

⇢Launch⇢#00FF00
⇢Abort⇢#FF0000

The # menu suffix can also be used in a menu definition. This changes the color of the entire menu (unless overridden for individual items). In this example all of the oceans listed in the menu will be blue.

(Oceans)⇢#0000FF
⇢Pacific
⇢Atlantic
⇢Indian

To specify a custom font and size for a menu item, insert @ into the menu item suffix, followed by the name of the font, a colon, the size, and finally the semicolon (;) character.

⇢School⇢@Chalkduster:15;
⇢Wedding⇢@Snell Roundhand:24;
⇢Work⇢@Gill Sans:14;

If you want to use the standard font with a different size, you can leave the font name off.

⇢Big⇢@18;
⇢Biggest⇢@24;
⇢Huge⇢@36;

Or, you can specify only the font, using the standard size:

⇢Comments⇢@Noteworthy Light;

The @ menu suffix can also be used in a menu definition. This changes the font of the entire menu (unless overridden for individual items). In this example all of the oceans listed in the menu will displayed using 18 point Optima ExtraBlack (and will also be blue).

(Oceans)⇢#0000FF@Optima ExtraBlack:18;
⇢Pacific
⇢Atlantic
⇢Indian

To indent a menu item, insert + into the menu item suffix, followed by a digit from 1 to 9. The larger the number, the larger the indent.

(Offices)
⇢California
⇢Los Angeles+1
⇢Downtown+2
⇢LAX+2
⇢San Francisco+1
⇢Sacramento+1
⇢Arizona
⇢Phoenix+1
⇢Tuscon+1
⇢Flagstaff+1

An image can be inserted at the left of a menu item by putting the image name in the menu item suffix between ɛ and ɜ characters (the best way to create these characters is to copy them from this page and paste them into your text.) This example displays a red circle with an exclamation mark next to the menu item, you might want to do this if the credit card number was invalid or missing (see cardvalidate().

⇢Charge Credit Card⇢ɛRedBangCircle14pxɜ

At this time, only images that are contained within Panorama itself can be displayed in a menu, you cannot supply your own images.

If the first character of the menu item is √ or - the menu will be marked. In this example the Green menu item will be checked.

⇢Red
√⇢Green
⇢Blue

In the example above the mark character was placed in the menu item prefix, which is the best practice. However, you can leave off the prefix and include the mark in the menu title, like this:

Red
√Green
Blue

Panorama will automatically extract the checkmark from the Green menu item name.

To give a menu item an identifier, insert the identifier, surrounded by $ and ɜ characters, into the menu item suffix.

⇢Red⇢$redColorɜ{call setColor}

The identifier does not change the appearance or operation of the menu item in any way, however, the procedure triggered by this menu item can use the info(“menuidentifier”) function to find out what the identifier is. This allows you to create procedures that don’t depend on the actual menu title. For example, you could translate the menu title into French or Spanish without breaking your menu procedure programming.

⇢Rouge⇢$redColorɜ{call setColor}
⇢Rojo⇢$redColorɜ{call setColor}

Combining Multiple Menu Options

Most of the examples above have shown menu item options used one at a time, but you can combine multiple options simply by concatenating them together.

⇢Void Invoice⇢{call VoidInvoice}#FF0000<B/⇧⌥V

This menu item has four options:


See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0, but with many new features, including modifier masks on menu key equivalents, alternate menu items, menu actions, menu item color, font and text size, indentation, images, and menu item identifiers.