Class ShortcutContext

The ShortcutContext class implements a shortcut context that can hold a set of ShortcutAction.

Each context has a name, a priority and a set of actions to be executed. Contexts can be disabled. If a context is disabled, none of it's action will be triggered and all shortcuts will be unregistered from the shortcut manager.

Hierarchy

  • FrameworkObject
    • ShortcutContext

Constructors

  • Parameters

    • OptionalisInternalConstructor: boolean

    Returns ShortcutContext

Accessors

  • get displayName(): string
  • The context display name to be used in UIs.

    Returns string

  • set displayName(value): void
  • Parameters

    • value: string

    Returns void

  • get isEffectivelyEnabled(): boolean
  • Checks if the context is "effectively enabled", that is, it and all it's parent contexts are in enabled status.

    Returns boolean

  • get isEnabled(): boolean
  • A toggle that can be used to enable or disable the context. This does not dictate whether the context is effectively enabled or disabled, to check for it's effective status, taking parent contexts into consideration, use IsEffectivelyEnabled

    Returns boolean

  • set isEnabled(value): void
  • Parameters

    • value: boolean

    Returns void

  • get name(): string
  • Gets the context name.

    Returns string

  • get path(): string
  • Gets the context full path.

    Returns string

  • get priority(): number
  • A property that defines the base priority for all actions in this context and children contexts.

    Returns number

  • set priority(value): void
  • Parameters

    • value: number

    Returns void

Methods

  • Adds a new shortcut action. If an action with the same name already exists, the creation fails.

    Parameters

    • name: string

      The shortcut action name.

    • identifier: string
    • Optionalcallback: (() => void)

      A callback to be called everytime any time the shortcut is triggered.

        • (): void
        • Returns void

    • Optionalkey: ShortcutKey

      A default key binding to be set on action.

    • Optionalflags: EnumValue<ShortcutBindingFlag, number>

      A set of flags that control the behavior of the action.

    • Optionalpriority: number

      The action priority. Actions and contexts with higher priorities will take precedence over lower priorities if the same shortcut key is bound to different actions.

    Returns ShortcutAction

    A the newly added shortcut action or null if the action was already created.

  • Adds a new child context. If an context with the same name already exists, it updates the priority of the existing context and returns it.

    By creating a new child context, you can more easily control actions by using a hierarchy of contexts. Disabling a parent context will disable all children contexts and their actions too.

    Parameters

    • name: string

      The child context name.

    • Optionalpriority: number

      The context base priority. Actions and contexts with higher priorities will take precedence over lower priorities if the same shortcut key is bound to different actions.

    Returns ShortcutContext

    A pointer to the newly added shortcut context or nullptr if the context was already created.

  • Searches and returns for an action with the given name. If no such action exists, nullptr is returned.

    Parameters

    • name: string

    Returns ShortcutActionBase

  • Searches and returns for an action with the given key combination. If no such action exists, nullptr is returned.

    Parameters

    Returns ShortcutActionBase

  • Searches and returns for a child context with the given name. If no such child context exists, nullptr is returned.

    Parameters

    • name: string

    Returns ShortcutContext

  • Searches and returns for a child context with the given name. If no such child context exists, a new one with the given name is created and returned.

    Parameters

    • name: string

    Returns ShortcutContext

  • Finds a context by it's path. The path is defined as a sequence of context names separated by "/".

    Parameters

    • path: string

    Returns ShortcutContext

  • Checks if the context has an action named name.

    Parameters

    Returns boolean

  • Checks if the context has a child context with the given name.

    Parameters

    • name: string

    Returns boolean

  • Removes a shortcut action by it's name.

    Parameters

    • name: string

    Returns boolean

  • Removes a child context by name.

    Parameters

    • name: string

    Returns boolean