This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20 R7
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 Character code is passed in itemKey)
process  Longint in Process reference number

The SET MENU ITEM SHORTCUT command assigns a new shortcut to a menu item. 

The menu item is defined through the menu and menuItem parameters. You can pass -1 in menuItem to target the last item added to the menu

In itemKey, pass a string that indicates the shortcut key. The new shortcut will automatically include the Ctrl (Windows) or Cmd (macOS) modifier by default. For example, passing "U" in itemKey sets the shortcut to Ctrl + U (Windows) or Cmd + U (macOS).

Note: You can designate an F-key by passing "[Fx]" to itemKey, for example "[F4]". In this case, no modifier is added by default.

In modifiers, you can pass additional modifiers to the shortcut, such as the Shift key. This way, you can define shortcuts like Ctrl+Alt+Shift+Z (Windows) or Cmd+Option+Shift+Z (macOS). Pass 0 if you don't want to add any modifiers. The following constants are available:

  • Command key mask for the Command (macOS) or Ctrl (Windows) key 
  • Shift key mask for the Shift key
  • Option key mask for the Option (macOS) or Alt (Windows) key 

To set a shortcut with several modifiers, just combine the above constants.

If you omit the process parameter, SET MENU ITEM SHORTCUT applies to the menu bar for the current process. Otherwise, the command 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.

For compatibility reasons, the command also accepts a character code in the itemKey parameter (former syntax). In this case, the shortcut automatically includes the Ctrl (Windows) or Cmd (macOS) key and the modifiers parameter is not taken into account. 

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)

Definition of the F4 shortcut for the "Close" menu item:

 INSERT MENU ITEM(FileMenu;-1;"Close")
 SET MENU ITEM SHORTCUT(FileMenu;-1;"[F4]";0)



See also 

Get menu item key
Get menu item modifiers

 
PROPERTIES 

Product: 4D
Theme: Menus
Number: 423

Not for server

 
PAGE CONTENTS 
 
HISTORY 

Modified: 4D v11 SQL

 
ARTICLE USAGE

4D Language Reference ( 4D v20 R7)