Blitz3D+ Command Reference

SetHotKeyField hotkey,rawkey[,modifiers]

Parameters

hotkey - hotkey field gadget

rawkey - raw scan code of the key, as used by KeyDown and HotKeyEvent; 0 clears the field

modifiers (optional) - modifier bits, added together; 0 (default)
1: Shift
2: Control
4: Alt

Description

Programs a hotkey field with a key and modifier combination.

Requires Extended language mode.

A hotkey field displays a shortcut and lets the user press a new one; this command sets it from code - typically to show the shortcut loaded from your tool's saved settings. Read the current combination back with HotKeyFieldKey and HotKeyFieldModifiers.

The field only captures the combination - it does not make the shortcut live. Pass the captured values to HotKeyEvent to actually install it, and again with event id 0 to remove the old one first:

If currentKey<>0 Then HotKeyEvent currentKey,currentModifiers,0
currentKey=HotKeyFieldKey(field) : currentModifiers=HotKeyFieldModifiers(field)
If currentKey<>0 Then HotKeyEvent currentKey,currentModifiers,MY_EVENT

Setting from code is silent; when the user presses a combination the field posts a critical $401 with the raw key in EventData and the modifiers in EventX. Impossible combinations - a raw key outside 0-255, an unknown scan code, modifier bits above 7, or modifiers with rawkey 0 - stop with a runtime error.

See it working in the native input controls sample.

See also: CreateHotKeyField, HotKeyFieldKey, HotKeyFieldModifiers, HotKeyEvent, KeyDown.

Index