Navigation: ABC Library Reference > PopupClass > PopupClass Methods >====== AddMenu (add a menu) ====== | |
AddMenu( selections [, position ] )
AddMenu | Adds a popup menu. |
selections | A string constant, variable, EQUATE, or expression containing the text for the popup menu choices. |
position | An integer constant, variable, EQUATE, or expression containing the position within the PopupClass' existing menu at which to add the selections. If omitted or zero (0), AddMenu clears any existing menu selections. |
The AddMenu method adds an entire popup menu or adds additional selections to an existing menu. The AddMenu method creates a popup menu item with a unique name for each text specified by the selections parameter. The selections parameter is identical to the selections parameter for the POPUP command. See POPUP in the Language Reference for more information.
You set the action taken for each menu item with the AddItemMimic or AddItemEvent methods, or with your own custom code. These methods (and your code) must refer to the menu items by name (not by text).
Implementation:
The AddMenu method optionally replaces any previously defined menu for this PopupClass object.
The Ask method displays the popup menu and returns the selected item's name.
The Popup class object derives the menu item name from its text. Each derived item name is the same as its text minus any special characters. That is, the name contains only characters 'A-Z', 'a-z', and '0-9'. If the resulting name is not unique, the PopupClass appends a sequence number to the name to make it unique.
The selections parameter accepts up to 10,000 characters.
Example:
MenuChoices EQUATE('&Save Menu|&Restore Menu|-|&Close')!declare menu definition string |
CODE |
PopupMgr.AddMenu(MenuChoices) !add Popup menu |
PopupMgr.AddItemMimic('SaveMenu',?Save) !SaveMenu mimics ?Save button |
PopupMgr.AddItemEvent('Close',EVENT:Accepted,?Close) !Close POSTs event to a control |
!program code |
IF PopupMgr.Ask() = 'RestoreMenu' !if RestoreMenu item selected |
PopupMgr.Restore('MyMenu') !code your own functionality |
ELSE !if any other item selected |
END !Ask automatically handled it |
See Also: AddItemEvent, AddItemMimic, Ask