Hotkey#

class omni.kit.widget.toolbar.Hotkey(
action_name: str,
hotkey: KeyboardInput,
on_action_fn: Callable[[], None],
hotkey_enabled_fn: Callable[[], bool],
modifiers: int = 0,
on_hotkey_changed_fn: Callable[[str], None] = None,
)#

Bases: object

A helper class to add hotkey to a Toolbar widget.

Hotkey registers an Action with `omni.kit.actions.core` and assigns a hotkey using `omni.kit.hotkeys.core`. If `omni.kit.hotkeys.core` is not enabled, hotkey will not be in effect.

Methods

__init__(action_name, hotkey, on_action_fn, ...)

Initialize a Hotkey object.

clean()

Cleanup function to be called before Hotkey object is destroyed.

get_as_string(default)

Gets the string representation of the hotkey combo.

__init__(
action_name: str,
hotkey: KeyboardInput,
on_action_fn: Callable[[], None],
hotkey_enabled_fn: Callable[[], bool],
modifiers: int = 0,
on_hotkey_changed_fn: Callable[[str], None] = None,
)#

Initialize a Hotkey object.

Parameters:
  • action_name (str) – The Action name associated with the hotkey. It needs to be unique.

  • hotkey (carb.input.KeyboardInput) – The keyboard key binding.

  • on_action_fn (Callable[[], None]) – Callback function to be called when Action is triggered.

  • hotkey_enabled_fn (Callable[[], bool]) – Predicate callback function to be called when Action is triggered, but before `on_action_fn` to determine if it should be called.

  • modifiers (int) – Modifier of the hotkey.

  • on_hotkey_changed_fn (Callable[[str], None]) – Callback function when Hotkey is reassigned by external system such as `omni.kit.hotkeys.window`. The parameter will be the new key combo.

clean()#

Cleanup function to be called before Hotkey object is destroyed.

get_as_string(default: str) str#

Gets the string representation of the hotkey combo. Useful as tooltip.