4D v14.3

Menu selected

Home

 
4D v14.3
Menu selected

Menu selected 


 

Menu selected {( subMenu )} -> Function result 
Parameter Type   Description
subMenu  MenuRef in Reference of menu containing item selected
Function result  Longint in Menu command selected Menu number in high word Menu item number in low word

Menu selected is used only when forms are displayed. It detects which menu command has been chosen from a menu and, in the case of a hierarchical submenu, returns the reference of the submenu.

Tip: Whenever possible, use methods associated with menu commands in an associated menu bar (with a negative menu bar number) instead of using Menu selected. Associated menu bars are easier to manage, since it is not necessary to test for their selection.

The Menu selected command can be used to work with hierarchical submenus. When selecting a hierarchical menu item beyond the first level, the command returns, in the optional subMenu parameter, the reference (MenuRef type, 16-character string) of the submenu to which the selected item belongs. If the menu command does not contain a hierarchical submenu, this parameter receives an empy string.

Menu selected returns the menu-selected number, a long integer. To find the menu number, divide Menu selected by 65,536 and convert the result to an integer. To find the menu command number, calculate the modulo of Menu selected with the modulus 65,536. Use the following formulas to calculate the menu number and menu command number:

 Menu:=Menu selected\ 65536
 menu command:=Menu selected% 65536

You can also extract these values using the bitwise operators as follows:

 Menu:=(Menu selected & 0xFFFF0000)>>16
 menu command:=Menu selected & 0xFFFF

If no menu commands are selected, Menu selected returns 0.

Example  

The following form method uses Menu selected to supply the menu and menu item arguments to SET MENU ITEM MARK:

 Case of
    :(Form event=On Menu Selected)
       C_STRING(16;$refMenuIncludingItem)
       C_LONGINT($ref;$MenuNum;$MenuItemNum)
       $ref:=Menu selected($refMenuIncludingItem)
       $MenuNum:=$ref\65536
       $MenuItemNum:=$ref%65536
       SET MENU ITEM MARK($refMenuIncludingItem;$MenuItemNum;Char(18))
 End case

Note: The On Menu Selected form event is not activated if no item is selected, $refMenuIncludingItem is always given a value and $MenuNum equals 0 if the menu is not one of the menus of the menu bar.

 
PROPERTIES 

Product: 4D
Theme: Menus
Number: 152

Not for server

 
HISTORY 

Modified: 4D v11 SQL

 
SEE ALSO 

Managing Menus

 
ARTICLE USAGE

4D Language Reference ( 4D v12.4)
4D Language Reference ( 4D v11 SQL Release 6)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)