| **Navigation:**  [[abc library reference.htm|ABC Library Reference]] > PopupClass > PopupClass Methods >====== AddMenu (add a menu) {{c6h0009.jpg|C6H0009.jpg}} ====== | [[additemmimic tie menu item to a button .htm|{{btn_prev_n.gif|Previous page}}]][[abc library reference.htm|{{btn_home_n.gif|Return to chapter overview}}]][[addsubmenu add submenu .htm|{{btn_next_n.gif|Next page}}]] | | || **AddMenu( **//selections //[//, position //]// //**)** {{blk2blue.jpg|blk2blue.jpg}} | **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 set menu item action .htm|AddItemEvent]], [[additemmimic tie menu item to a button .htm|AddItemMimic]], [[ask display the popup menu .htm|Ask]]