4D v16.3

SET MENU ITEM SHORTCUT

Home

 
4D v16.3
SET MENU ITEM SHORTCUT

SET MENU ITEM SHORTCUT 


 

SET MENU ITEM SHORTCUT ( menu ; menuItem ; itemKey ; modifiers {; process} ) 
Parameter Type   Description
menu  Longint, MenuRef in Menu number or Menu reference
menuItem  Longint in Menu item number or -1 for last item added
itemKey  String, Longint in Letter of keyboard shortcut or Character code of keyboard shortcut (former syntax)
modifiers  Longint in Modifier(s) to associate with shortcut (ignored if key code is passed)
process  Longint in Process reference number

The SET MENU ITEM SHORTCUT command replaces the shortcut key associated with the menu command specified by menu and menuItem, by the character whose character code or text is passed in itemKey. You can pass -1 in menuItem in order to indicate the last item added to menu. This key is combined with the Ctrl (Windows) or Command (Macintosh) key in order to set the new keyboard shortcut.

You can pass the letter indicating the shortcut key in the itemKey parameter, for example “U” to specify the Ctrl+U (Windows) or Command+U (Mac OS) shortcut. You can pass additional modifiers to associate with the shortcut in the modifiers parameter. This way you can define shortcuts like Ctrl+Alt+Shift+Z (Windows) or Cmd+Option+Shift+Z (Mac OS).

You can pass the following values in modifiers:

  • 256 for the Command (Mac OS) or Ctrl (Windows) key
  • 512 for the Shift key
  • 2048 for the Option (Mac OS) or Alt (Windows) key
  • To associate several different keys, just combine their values.

Note: You can specify the value to pass using the Command key mask, Shift key mask and Option key mask constants of the Events (Modifiers) theme.

The Ctrl (Windows) and Command (Mac OS) keys are automatically added by 4D to the keyboard shortcut, regardless of whether or not you explicitly indicate it in the modifiers parameter. So you do not have to add the value 256 to this parameter, unless this key is the only modifier, in which case you must pass either the value 256 or the corresponding constant in modifiers.

Note: For compatibility, the command also accepts a character code in the itemKey parameter (former syntax). In this case, the modifiers parameter is not taken into account and can be omitted. The shortcut is only associated with the Ctrl (Windows) or Command (Mac OS) key.

If you omit the process parameter, SET MENU ITEM SHORTCUT applies to the menu bar for the current process. Otherwise, SET MENU ITEM SHORTCUT applies to the menu bar for the process whose reference number is passed in process.

Note: If you pass a MenuRef in menu, the process parameter serves no purpose and will be ignored.

If you pass 0 (zero) in itemKey, any shortcut is removed from the menu item.

Definition of the Ctrl+Shift+U (Windows) and Cmd+Shift+U (Mac OS) shortcut for the “Underline” menu item:

 SET MENU ITEM(menuRef;1;"Underline")
 SET MENU ITEM SHORTCUT(menuRef;1;"U";Shift key mask)

Definition of the Ctrl+R (Windows) and Cmd+R (Mac OS) shortcut for the "Restart" menu item:

 INSERT MENU ITEM(FileMenu;-1;"Restart")
 SET MENU ITEM SHORTCUT(FileMenu;-1;"R";Command key mask)



See also 

Get menu item key
Get menu item modifiers

 
PROPERTIES 

Product: 4D
Theme: Menus
Number: 423

Not for server

 
HISTORY 

Modified: 4D v11 SQL

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)