HotKeyEvent rawkey,modifier,ev_id[,ev_data][,ev_x][,ev_y][,ev_z][,ev_source]
Parameters
|
rawkey - keyboard scan code of the shortcut key (the same codes key events carry in EventData) modifier - modifier keys that must be held, added together: Shift 1, Control 2, Alt 4; 0 for the bare key ev_id - event id to post when the combination is pressed; 0 removes the shortcut registered for rawkey+modifier ev_data (optional) - EventData of the posted event; 0 (default) ev_x (optional) - EventX of the posted event; 0 (default) ev_y (optional) - EventY of the posted event; 0 (default) ev_z (optional) - EventZ of the posted event; 0 (default) ev_source (optional) - EventSource of the posted event; 0 (default) |
Description
|
Installs a keyboard shortcut that posts an event of your choosing when pressed. Requires Extended language mode. This is how a tool gets working accelerators - Ctrl+S to save, F5 to run - without every gadget having to watch for keys. Whenever the combination is pressed anywhere in your program, an event built from your ev_ values lands on the shared queue, and your normal WaitEvent loop handles it like anything else. Pick your own ev_id values, well away from the built-in families, and route on them. The shortcut is application-wide but not system-wide: it fires whichever of your gadgets has focus, but only while your program is in the foreground. The keystroke is consumed - the focused gadget never sees the key - and it fires once per press, with no auto-repeat. The modifier set must match exactly: a Ctrl+S binding does not fire on Ctrl+Shift+S. Calling again with the same rawkey and modifier replaces the registered event, and ev_id 0 removes it. Up to 100 combinations can be registered at once; going past that stops with a runtime error. Pairs naturally with a hotkey field: CreateHotKeyField lets the user capture a combination, HotKeyFieldKey and HotKeyFieldModifiers read it, and HotKeyEvent makes it live. See it working in the native input controls sample, which rebinds a working shortcut on the fly. See also: CreateHotKeyField, SetHotKeyField, HotKeyFieldKey, HotKeyFieldModifiers, WaitEvent, EventID. |
Index