version 11 (Modified)
SET MENU ITEM SHORTCUT (menu; menuItem; itemKey{; modifiers{; process}})
Parameter | Type | Description | |
menu | Number | MenuRef | Menu number or Menu reference | |
menuItem | Number | Menu item number or | |
-1 for last item added | |||
itemKey | Number | Text | Character code of keyboard shortcut or | |
Letter of keyboard shortcut | |||
modifiers | Longint | Modifier(s) to associate with shortcut | |
(ignored if key code is passed) | |||
process | Number | Process reference number |
Description
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 will automatically be combined with the Ctrl (Windows) or Command (Macintosh) key in order to set the new keyboard shortcut.
You can pass the name of the key directly as text (a letter) in the itemKey parameter, for example "U" to specify the Ctrl+U (Windows) or Command+U (Mac OS) shortcut. When you use this syntax, you can also pass the optional modifiers parameter in order to associate additional modifiers with the shortcut. This way you can define shortcuts of the Ctrl+Alt+Shift+Z (Windows) or Cmd+Option+Shift+Z (Mac OS) type.
To do this, pass the following values in modifiers:
512 for the Shift key
2048 for the Option (Mac OS) or Alt (Windows) key
To associate both keys, combine their values.
Note that the Ctrl (Windows) and Command (Mac OS) keys are automatically added by 4D to the keyboard shortcut.
Note: You can specify the value to pass using the Shift key mask and Option key mask constants of the "Events (Modifiers)" theme.
If passed, the modifiers parameter is not taken into account when the shortcut key is specified via a character code (former syntax).
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.
Example
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)
See Also
Get menu item key, Get menu item modifiers.