Registry of commands: named actions with an optional icon and an optional shortcut key, each firing one callback when invoked (clicked from a menu / toolbar, or via its key).
More...
|
| UndoHistory & | History () |
| | The app's undo history (text fields push their edits to it).
|
| const UndoHistory & | History () const |
| | CommandManager () |
| CommandMode | RegisterMode (std::string_view name) |
| | Registers a named mode and returns the CommandMode to use when registering commands or calling SetMode.
|
| std::string_view | GetModeName (CommandMode mode) const |
| | The name mode was registered with; empty for an unknown mode.
|
| uint32_t | GetModeCount () const |
| void | SetMode (CommandMode mode) |
| | Makes mode the active mode, whose shortcuts are tried before Default.
|
| CommandMode | GetMode () const |
| CommandID | RegisterCommand (CommandMode mode, IconID icon, KeyCode key, KeyModifier modifiers, std::function< void()> callback, std::string_view description={}) |
| | Registers callback in mode; description names it in menus and shortcut lists.
|
| CommandID | RegisterCommand (IconID icon, KeyCode key, KeyModifier modifiers, std::function< void()> callback, std::string_view description={}) |
| | RegisterCommand in the Default mode.
|
| CommandID | RegisterCommand (CommandMode mode, KeyCode key, KeyModifier modifiers, std::function< void()> callback, std::string_view description={}) |
| | RegisterCommand without an icon.
|
| CommandID | RegisterCommand (KeyCode key, KeyModifier modifiers, std::function< void()> callback, std::string_view description={}) |
| | RegisterCommand in the Default mode, without an icon.
|
| CommandID | RegisterCommand (CommandMode mode, IconID icon, std::function< void()> callback, std::string_view description={}) |
| | RegisterCommand without a shortcut key.
|
| CommandID | RegisterCommand (IconID icon, std::function< void()> callback, std::string_view description={}) |
| | RegisterCommand in the Default mode, without a shortcut key.
|
| CommandID | RegisterHeldCommand (CommandMode mode, IconID icon, KeyCode key, KeyModifier modifiers, std::function< void()> onBegin, std::function< void()> onEnd, std::string_view description={}) |
| | Registers a hold-to-act command (pan, orbit): onBegin on press, onEnd on release.
|
| CommandID | RegisterHeldCommand (KeyCode key, KeyModifier modifiers, std::function< void()> onBegin, std::function< void()> onEnd, std::string_view description={}) |
| | RegisterHeldCommand in the Default mode, without an icon.
|
| CommandID | RegisterHeldCommand (CommandMode mode, KeyCode key, KeyModifier modifiers, std::function< void()> onBegin, std::function< void()> onEnd, std::string_view description={}) |
| | RegisterHeldCommand without an icon.
|
| CommandID | FindCommand (CommandMode mode, KeyCode key, KeyModifier modifiers) const |
| | The single-key command bound to (mode, key, modifiers); Invalid if none.
|
| CommandID | FindChord (CommandMode mode, KeyCode k1, KeyModifier m1, KeyCode k2, KeyModifier m2) const |
| | The chord command in mode bound to exactly k1+m1 then k2+m2; Invalid if none.
|
| CommandID | RegisterChord (CommandMode mode, KeyCode key1, KeyModifier mods1, KeyCode key2, KeyModifier mods2, std::function< void()> callback, std::string_view description={}) |
| | Registers a 2-key chord command (e.g.
|
| EventHandler | MakeHandler () |
| | An EventHandler to push onto the InputManager as a global handler.
|
| const std::vector< Command > & | GetCommands () const |
| | Every command, in registration order: the one at index i has CommandID{ i + 1 }.
|
| const Command * | GetCommand (CommandID id) const |
| | The command, or null for an invalid or unknown ID.
|
| const std::vector< CommandID > & | GetCommandsForMode (CommandMode mode) const |
| | Handles for a given mode, in registration order.
|
| void | BeginRebind (CommandID id) |
| | Makes the next non-modifier keydown the shortcut of id instead of firing anything.
|
| void | CancelRebind () |
| bool | IsRebinding () const |
| CommandID | RebindTarget () const |
| void | SetShortcut (CommandID id, KeyCode key, KeyModifier modifiers) |
| | Gives id the shortcut (key, modifiers), as a rebind does: another command in its mode that had it is left without one.
|
| bool | IsChordPending () const |
| | True while a chord prefix was pressed and awaits its second key.
|
| bool | ProcessInput (const InputState &state) |
| | Runs a keydown InputState through rebind / chord / shortcut dispatch; true when it handled the key.
|
| bool | ProcessKeyUp (const InputState &state) |
| | Fires onEnd of every active held command on the released key (modifiers are ignored); true if any fired.
|
Registry of commands: named actions with an optional icon and an optional shortcut key, each firing one callback when invoked (clicked from a menu / toolbar, or via its key).
Commands are organized by named modes.
Modes are registered by name and return an opaque CommandMode:
CommandMode sculpt = commandManager.RegisterMode("Sculpt");
commandManager.RegisterCommand(sculpt, KeyCode::KeyG, KeyModifier::None, []{ ... }, "Grab");
A command may have no shortcut key (KeyCode::None): it never dispatches from the keyboard but is still listed in the panel, where the user can bind a key.
Runs as a global InputManager handler (MakeHandler), so focused controls, a focused text editor and state.consumed all take keys first.
Shortcut lookup order: active mode first, then Default as fallback.