Skip to main content
Version: Next

OBJECT SET SHORTCUT

OBJECT SET SHORTCUT ( {* ;} object ; key {; modifiers} )

ParameterTypeDescription
*OperatorIf specified, object is an object name (string)If omitted, object is a variable or field
objectanyObject Name (if * is specified) or Variable or field (if * is omitted)
keyTextKey to associate with object
modifiersIntegerModifier key mask or combination of masks

This command is not thread-safe, it cannot be used in preemptive code.

Description

The OBJECT SET SHORTCUT command sets or dynamically modifies the keyboard shortcut associated with the object(s) designated by the object and * parameters for the current process.

If you pass the optional * parameter, this indicates that the object parameter is an object name (a string). If you do not pass this parameter, this indicates that the object is a variable or a field. In this case, you pass a reference instead of a name.

In the key parameter, pass a string indicating the key to associate with the object. You can either pass:

  • a standard key name, for example "B"
  • or a constant (or its value) from the Shortcut and Associated Keys theme:
ConstantTypeValueComment
Shortcut with BackspaceText[backspace]
Shortcut with Carriage ReturnText[return]
Shortcut with DeleteText[del]
Shortcut with Down arrowText[down arrow]
Shortcut with EndText[end]
Shortcut with EnterText[enter]
Shortcut with EscapeText[esc]
Shortcut with F1Text[F1]
Shortcut with F10Text[F10]
Shortcut with F11Text[F11]
Shortcut with F12Text[F12]
Shortcut with F13Text[F13]
Shortcut with F14Text[F14]
Shortcut with F15Text[F15]
Shortcut with F2Text[F2]
Shortcut with F3Text[F3]
Shortcut with F4Text[F4]
Shortcut with F5Text[F5]
Shortcut with F6Text[F6]
Shortcut with F7Text[F7]
Shortcut with F8Text[F8]
Shortcut with F9Text[F9]
Shortcut with HelpText[help]
Shortcut with HomeText[home]
Shortcut with Left arrowText[left arrow]
Shortcut with Page downText[page down]
Shortcut with Page upText[page up]
Shortcut with Right arrowText[right arrow]
Shortcut with TabulationText[tab]
Shortcut with Up arrowText[up arrow]

In the modifiers parameter, you can pass one or more modifier keys to associate with the shortcut. To set the modifiers parameter, pass one or more of the following "Mask" type constants found in the Events (Modifiers) theme:

ConstantTypeValueComment
Command key maskInteger256Ctrl key under Windows, Command key under OS X
Control key maskInteger4096Ctrl key under OS X, or right click under Windows and OS X
Option key maskInteger2048Alt key (also called Option under OS X)
Shift key maskInteger512Windows and OS X

Note: When you omit the modifiers parameter, the object is enabled as soon as you press the key that was set. For example, if you associate the "H" key with a button, this button is enabled whenever you press the H key. This kind of functioning is to be reserved for specific interfaces.

Example

You want to associate a different shortcut depending on the current language of the application. In the On Load form event, you can write:

 Case of
       vLang="FR"
       OBJECT SET SHORTCUT(*;"SortButton";"T";Command key mask+Shift key mask) // Ctrl+Shift+T in French
       vLang="US"
       OBJECT SET SHORTCUT(*;"SortButton";"O";Command key mask+Shift key mask) // Ctrl+Shift+O in English
 End case

See also

OBJECT GET SHORTCUT