at /druid/extended/hotkey.lua
Druid component to manage hotkeys and trigger callbacks when hotkeys are pressed.
Create hotkey component with druid: hotkey = druid:new_hotkey(keys, callback, callback_argument)
- Hotkey can be triggered by pressing a single key or a combination of keys
- Hotkey supports modificator keys (e.g. Ctrl, Shift, Alt)
- Hotkey can be triggered on key press, release or repeat
- Hotkey can be added or removed at runtime
- Hotkey can be enabled or disabled
- Hotkey can be set to repeat on key hold
hotkey:init(keys, callback, [callback_argument])The Hotkey constructor
- Parameters:
keys(string|string[]): The keys to be pressed for trigger callback. Should contains one key and any modificator keyscallback(function): The callback function[callback_argument](any): The argument to pass into the callback function
hotkey:add_hotkey(keys, [callback_argument])Add hotkey for component callback
-
Parameters:
keys(string|hash|hash[]|string[]): that have to be pressed before key pressed to activate[callback_argument](any): The argument to pass into the callback function
-
Returns:
self(druid.hotkey): Current instance
hotkey:is_processing()- Returns:
- `` (boolean):
hotkey:set_repeat(is_enabled_repeated)If true, the callback will be triggered on action.repeated
-
Parameters:
is_enabled_repeated(boolean): The flag value
-
Returns:
self(druid.hotkey): Current instance
hotkey:bind_node([node])If node is provided, the hotkey can be disabled, if the node is disabled
-
Parameters:
[node](node|nil): The node to bind the hotkey to. Nil to unbind the node
-
Returns:
self(druid.hotkey): Current instance
- on_hotkey_pressed (event): fun(self, context, callback_argument) The event triggered when a hotkey is pressed
- on_hotkey_released (event): fun(self, context, callback_argument) The event triggered when a hotkey is released
- style (druid.hotkey.style): The style of the hotkey component
- druid (druid.instance): The Druid Factory used to create components