menuitem(
menuitem(
TITLE
,
OPTION
,
VALUE
)

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

Parameters

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.

Description

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.

    menu("Medals")+
        menuitem("Gold")+
        menuitem("Silver")+
        menuitem("Bronze")

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

    menuitem(title,option1,value1,option2,value2,option3,value3)

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.

#### Menu Item Operation (CODE and ACTION options)

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",
        {
            addrecord
            TaxRate=9.25
            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 `paste:` 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.

#### Menu Key Equivalent (KEY option)

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 an alternate item 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","KEY","P")+
    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).

#### Submenus

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.

    submenu("Shippers")+
        menuitem("Airborne")+
        menuitem("Fedex")+
        menuitem("US Postal Service")+
        menuitem("UPS")

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.

#### Menu Item Styles (STYLE option)

To specify that a menu item be bold or italic, use the `STYLE` option:

    menuitem("Goal","STYLE","BOLD")
    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 Item Color (COLOR option)

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.

    menuitem("Launch","COLOR","00FF00")
    menuitem("Abort","COLOR","FF0000")

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

#### Menu Item Text Appearance (FONT and SIZE options)

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.

#### Menu Item Indentation (INDENT option)

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.

    menu("Offices")+
        menuitem("California")+
        menuitem("Los Angeles","INDENT",1)+
        menuitem("Downtown","INDENT",2)+
        menuitem("LAX","INDENT",2)+
        menuitem("San Francisco","INDENT",1)+
        menuitem("Sacramento","INDENT",1)+
        menuitem("Arizona")+
        menuitem("Phoenix","INDENT",1)+
        menuitem("Tuscon","INDENT",1)+
        menuitem("Flagstaff","INDENT",1)

#### Menu Item Image (IMAGE option)

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.

#### Menu Item State (STATE option)

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.

    menuitem("Red")+
    menuitem("Green","STATE","ON")
    menuitem("Blue")

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.

    menuitem("Red")+
    menuitem("Green","STATE","MIXED")
    menuitem("Blue","STATE","MIXED")

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.

#### Menu Item Identifier (IDENTIFIER option)

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},
        "COLOR","FF0000",
        "STYLE","BOLD",
        "KEY","SHIFT-OPTION-V")

This menu item has four options:

- call subroutine VoidInvoice if this menu item is chosen
- display menu title using red text
- display menu title in bold
- menu item has a command key equivalent of Command-Shift-Option-V

See Also

- Action Menu -- simple way to create your own menu items.
- arraymenuitems( -- converts a carriage return delimited array into a series of menu items.
- checkedarraymenuitems( -- converts a carriage return delimited array into a series of menu items, some of which may be checked.
- checkedmenuitem( -- creates a single menu item with an optional checkmark.
- Construct Menu -- used to automatically construct complex form applications, including calendars, lists, mailing labels, and more.
- Edit Menu -- edit text and data, to search (and replace), and to undo and recent actions.
- Field Menu -- manages fields, including adding and removing fields, setting field properties, sorting, morphing, hiding and showing.
- File Menu -- create, locate, open, close and save databases, import and export text, printing.
- filemenubar -- creates a custom menu bar or context menu for the current database (see Custom Menus).
- globalmenubar -- creates a custom menu bar or context menu for all windows (intended only for internal use by ProVUE Development).
- Help Menu -- contains items that will help you learn and use Panorama.
- info("menuidentifier") -- returns the identifier of the most recently chosen menu item (if any).
- LMSL -- is the specification language for Live Menus.
- Mark Menu -- allows you to set bookmarks in source code to help navigate to specific spots in a long program.
- menu( -- creates a menu (see Custom Menus).
- menuitems( -- converts a semicolon separated array into a live menu specification.
- Menus -- overview of Panorama X menu bars.
- menuseparator( -- generates a menu item separator
- noactionmenu( -- suppresses the *Action* menu.
- noinstrumentationmenu( -- supresses the *Instrumentation* menu.
- nowizardmenu( -- suppresses the *Wizards* menu.
- Objects Menu -- used to select, modify and arrange graphics objects in a form.
- Panorama Menu -- get and set information about Panorama itself, including the version number, licensing information, and memory usage.
- popupatmouse -- displays a pop-up menu at the current mouse location.
- popupbelowbutton -- displays a pop-up menu in response to clicking on a button.
- popupclick -- displays a pop-up menu at the current mouse location.
- popupdoublefieldchoices -- displays a pop-up menu listing values in a specified field, with submenus containing values from a second field.
- popupfieldchoices -- displays a pop-up menu listing values in a specified field.
- Program Menu -- assists with running and debugging code, and with developing custom dialogs.
- Records Menu -- add and remove database records.
- Search Menu -- is used search for data, to select records, and to find and replace text within the current field.
- Source Menu -- used to assist in editing program code.
- standardactionmenu( -- generates a Custom Menu specification for Panorama's standard Action menu.
- standardclassicsetupmenu( -- generates a customizable Custom Menu specification for Panorama's classic Setup menu.
- standardconstructgraphicsmenu( -- generates a Custom Menu specification for Panorama’s standard Construct menu (in Graphics Mode).
- standardeditmenu( -- generates a customizable Custom Menu specification for Panorama's standard Edit menu.
- standardfieldsmenu( -- generates a customizable Custom Menu specification for Panorama's standard Fields menu.
- standardfilemenu( -- generates a customizable Custom Menu specification for Panorama's standard File menu.
- standardhelpmenu( -- generates a customizable Custom Menu specification for Panorama's standard Help menu.
- standardinstrumentationmenu( -- generates a Custom Menu specification for Panorama’s standard Instrumentation menu.
- standardpanoramamenu( -- generates a Custom Menu specification for Panorama's standard Panorama menu.
- standardrecordsmenu( -- generates a customizable Custom Menu specification for Panorama's standard Records menu.
- standardsearchmenu( -- generates a customizable Custom Menu specification for Panorama's standard Search menu.
- standardsetupmenu( -- generates a customizable Custom Menu specification for Panorama's standard Setup menu.
- standardsortmenu( -- generates a customizable Custom Menu specification for Panorama's standard Sort menu.
- standardtextmenu( -- generates a customizable Custom Menu specification for Panorama's standard Text menu.
- standardviewmenu( -- generates a Custom Menu specification for Panorama's standard View menu.
- standardwindowmenu( -- generates a customizable Custom Menu specification for Panorama's standard Window menu.
- submenu( -- creates a submenu (see Custom Menus).
- Window Menu -- controls the back to front arrangement of windows, it allows you to hide, show, or customize the toolbar (see Toolbar, and allows you minimize or zoom the window to full screen.
- windowmenubar -- creates a custom menu bar or context menu for the current window (see Custom Menus).

History

Version | Status | Notes
10.0 | New | New in this version.