Application.ShowPopupMenu

number Application.ShowPopupMenu (

number  X,

number  Y,

table   Menu,

number  HAlign = TPM_LEFTALIGN,

number  VAlign = TPM_TOPALIGN,

boolean WaitForReturn = true,

boolean ClientCoordinates = true )

Description

Displays a popup (context) menu and returns the ID of the menu item clicked.

Tip: If you would like to show a popup menu when the user right-clicks on your application's system tray icon, see the built-in global function g_OnSystemTrayMenu.

Parameters

X

(number) The X coordinate in pixels.

Y

(number) The Y coordinate in pixels.

Menu

(table) A table of menu information, indexed by the following keys:

KEY

TYPE

DESCRIPTION

ID

number

The numeric ID of the menu item.

Text

string

The text of the menu item.  Use & before a letter to specify a mneumonic. Note that to create a separator item, set the item's Text to "---". In this case the ID, Checked, Enabled and SubTable items are ignored. Separator items will never fire an On Menu event.

Enabled

boolean

Whether the menu item is enabled.

Checked

boolean

Whether the menu item is checked.

IconID

number

The 0-based icon index from the Image List specified on the Menu Bar to use for the menu item. The Use image list checkbox must be checked for the icons to be available.

SubTable

table

A numerically indexed table of menu item tables. This creates a pop-up menu for this item.  Note that if a SubTable is specified this menu item will never fire the On Menu event.  Instead it's sub-items will fire the event.

HAlign

(number) The horizontal alignment of the menu relative to X.  Choose from the following constants:

CONSTANT

VALUE

DESCRIPTION

TPM_LEFTALIGN

0

Left-align the menu.

TPM_CENTERALIGN

4

Center-align the menu.

TPM_RIGHTALIGN

8

Right-align the menu.

VAlign

(number) The vertical alignment of the menu relative to X.  Choose from the following constants:

CONSTANT

VALUE

DESCRIPTION

PM_TOPALIGN

0

Top-align the menu.

TPM_VCENTERALIGN

16

Center-align the menu.

TPM_BOTTOMALIGN

32

Bottom-align the menu.

WaitForReturn

(boolean) Whether to wait for the context menu to be dismissed.  If set to true, the return value of Application.ShowPopupMenu will be the ID of the selected menu command or 0 if the menu is cancelled. If false, the menu command will fire to the On Menu event of the Project and Page when an item is selected.

Note: If set to false, g_OnUpdateMenuEnabled and g_OnUpdateMenuCheck will also be called when an item in the menu is selected. As well, if WaitForReturn is set to false, the menu commands that are used in the popup menu MUST be represented on the main menu bar as well.

ClientCoordinates

(boolean) True if the X and Y values should be relative to the top-left corner of the page, false if the X and Y values should be relative to the top-left corner of the user's screen.

Returns

(number) The ID of the menu item clicked. If an error occurs, -1 will be returned. You can use Application.GetLastError to determine whether this action failed, and why.

ResultVariable

When adding an action with the script editor, you can use this field to specify a variable that the return value will be stored in.

See also:  Related Actions