AddItemMimic (tie menu item to a button) 

Top  Previous  Next

 

AddItemMimic( name, button [, text ] ), PROC

AddItemMimic

Associates a menu item with a BUTTON.

name

A string constant, variable, EQUATE, or expression containing the menu item name to associate with the button. If the named item does not exist, AddItemMimic adds it at the bottom of the popup menu. To add a new item, the button must have text, or you must supply the text parameter.

button

A numeric constant, variable, EQUATE, or expression containing the associated BUTTON's control number. If the button has no text, you should supply the text parameter.

text

A string constant, variable, EQUATE, or expression containing the text of the menu item. Other PopupClass methods refer to the menu item by its name, not by its text. This lets you apply runtime translation or dynamic reordering of menus without changing your code. If omitted, AddItemMimic uses the button text as the text of the menu item.

The AddItemMimic method associates a menu item with a button and returns the name of the item. AddItemMimic can add a new menu item, or add an association to an existing menu item. The associated menu item text matches the button text, is enabled only when the button is enabled, and, when selected, invokes the button action.

Implementation:

The Ask method traps the selected item and POSTs an EVENT:Accepted to the button.

If button does not represent a BUTTON, AddItemMimic does nothing.

The text and name parameters accept up to 1024 characters.

Return Data Type:     STRING

Example:

PopupMgr.AddItem('Save Popup','Save')   !add menu item: Save

PopupMgr.AddItemMimic('Save',?Save)     !Save item mimics ?Save button

PopupMgr.AddItemMimic('Insert',?Insert) !add Insert item/mimic ?Insert button

See Also:     AddItem, AddMenu, Ask, SetText