The menuitem( function creates a single menu item (see Custom Menus).


This function has three parameters:

title – title of the menu item.

option – one or more options that modify the menu item. See below for descriptions of each option. The option name can be specified in either upper or lower case.

value – the value for the option specified in the previous parameter.


This function creates a single menu item (see Custom Menus) and should be used in conjunction with the menu( function and either the FileMenuBar statement or the WindowMenuBar statement. It would be wise to check out all of these before using this function. In its simplest form, the function has a single parameter, the title of the menu item. Here is a simple example of the function being used to create a menu with three menu items.


In addition to the title parameter, you can also specify one or more option/value pairs that modify the menu item, like this:


The rest of this page describes all of the option/value pairs that are available. Note: Most of the examples below show the option name in all upper case, for example STYLE or KEY, however, Panorama ignores upper and lower case, so key and Key will work just as well.

Choosing a menu item always triggers some action. There are two basic types of possible actions:

  1. Running a Panorama procedure, or
  2. Running an Objective-C method that is in the responder chain.

The code option allows you to specify the exact procedure statements to be triggered right in the menu item itself. In this example, when the Post Invoice menu item is chosen, a subroutine called invoiceOperation will be called with a single parameter.

menuitem("Post Invoice","CODE",{call invoiceOperation,"POST"})

Note: As shown in the example above, the code must be quoted. The example above uses { and } quotes, but you can choose different quote characters based on the text in your code (see Constants).

The code is not limited to a single statement, it can be as long as you want.

menuitem("New Invoice","CODE",
        Shipper=call("","Favorite Shipper")

The action option allows you to specify that an Objective-C method in the responder chain should be triggered by the menu. That’s fancy terminology for triggering internal Panorama code for standard operations like cut, copy, paste, saving, printing, etc.

menuitem("Page Setup","ACTION","runPageSetup:")

A benefit of using an Objective-C method is that the menu item will automatically be enabled/disabled as appropriate. For example, if you set up a menu item with the copy: method, it will automatically be disabled if there is nothing on the clipboard.

Default Menu Code/Action

If a menu item does not have any code or method assigned to it, 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 (this is the way Panorama 6.0 and earlier version worked for all menu items). 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.

Enabling/Disabling a Menu Item (ENABLED option)

This option allows you to disable a menu option. This example only enables the Charge Credit Card menu item if the CreditCard field contains a valid credit card number.

menuitem("Charge Credit Card","ENABLED",cardvalidate(CreditCard))

If the menu item action is an Objective-C method in the responder chain (see above), it will automatically disable itself if appropriate, even if you don’t use the Enabled option. For example, a menu item that uses the copy: action will automatically disable itself if there is nothing to copy.

To add a command key equivalent to a menu item, use the KEY option. The simplest form of this option is to supply a single character, which becomes the key equivalent. This example assigns Command-B as the key equivalent for the Open Book menu item.

menuitem("Open Book","KEY","B")

The modifiers SHIFT, OPTION or CONTROL can be added to the key equivalent. The options can be separated by dashes (as shown below), commas, spaces, or nothing at all, and can be listed in any order in upper or lower case. This example assigns the command key equivalent Command-Shift-Option-P to the Print Invoice menu item.

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 item is an alternate to the ones immediately above it, add the word ALTERNATE to the key equivalent value.

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.)

menuitem("Print One Record","KEY","ALTERNATE-OPTION-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 (the menu items will appear separately in the menu).

An entire menu can be used as 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 the submenu( function. This tells Panorama to define the menu, but not to include the menu in the main menu bar.

    menuitem("US Postal Service")+

Later in the menu definition formula you can attach this menu as a submenu to another menu item by using the SUBMENU option:

menuitem("Ship Via","SUBMENU","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, use the STYLE option:

menuitem("Triple Play","STYLE","ITALIC")
menuitem("Touchdown","STYLE","BOLD ITALIC")

The words BOLD and ITALIC can be in any order, can be separated by spaces, dashes, commas, or nothing at all (for example bolditalic), and can be in upper or lower case (or a mix).

Menu items are normally displayed in black, but you can use the COLOR option to choose any color you want. The color value is a 6 digit hex representation of the color (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.


You can also specify the default color for an entire menu, see the menu( function.

Menu items are normally displayed using the standard system font, but you can customize using any font and/or size you want.

menuitem("Register for Classes","FONT","Chalkduster")
menuitem("Wedding RSVP","FONT","Snell Roundhand","SIZE",24)
menuitem("Start Race","FONT","Gill Sans","SIZE",24)

You can also specify the default font and/or size for an entire menu, see the menu( function.

To indent a menu item use the INDENT option, with a value from 0 (no indent) to 9. The larger the number, the larger the indent.

    menuitem("Los Angeles","INDENT",1)+
    menuitem("San Francisco","INDENT",1)+

An image can be inserted at the left of a menu item by using the IMAGE option. 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().

menuitem("Charge Credit Card","IMAGE","RedBangCircle14px")

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

A menu item can be On, Off or Mixed (the default is Off). Use the STATE option to specify the state of a menu item. In this example the Green menu item will be checked.


If the menu state is Mixed, a dash is displayed instead of a checkmark. This is often used when multiple items are selected. In this example, both Green and Blue are selected.


You’ll often want to check one item out of a set. If the set is in a Text Arrays, the checkedarraymenuitems( function makes this easy.

To give a menu item an identifier, use the IDENTIFIER option.

menuitem("Red","IDENTIFIER","redColor","CODE","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.

menuitem("Rouge","IDENTIFIER","redColor","CODE","call setColor")
menuitem("Rojo","IDENTIFIER","redColor","CODE","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, as shown in this example.

menuitem("Void Invoice",
    "CODE",{call VoidInvoice},

This menu item has four options:

See Also


10.0NewNew in this version.