Expand description
egui-command-binding — keyboard shortcut → CommandId dispatch for egui apps.
Wraps egui-command types with egui-specific input handling.
ShortcutManager<C> scans egui Key events and returns a Vec<C> of
triggered commands — it never executes business logic directly.
§Quick-start
ⓘ
// Define your command type (typically a C: From<CommandId> enum).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
enum AppCmd { ShowHelp, PrevProfile, NextProfile }
// Build the global map once (e.g. in a lazy_static):
let mut global: ShortcutMap<AppCmd> = ShortcutMap::new();
global.insert(shortcut("F1"), AppCmd::ShowHelp);
global.insert(shortcut("F7"), AppCmd::PrevProfile);
global.insert(shortcut("F8"), AppCmd::NextProfile);
// Each frame, collect triggered commands:
let triggered = manager.dispatch(ctx);
for cmd in triggered { handle(cmd); }Re-exports§
pub use egui_command;
Macros§
- shortcut_
map - Build a
ShortcutMapfromshortcut_string => commandpairs.
Structs§
- Shortcut
- A keyboard shortcut: a key plus zero-or-more modifier keys.
- Shortcut
Manager - Scans egui key events each frame and returns triggered commands.
- Shortcut
Scope - A named, optionally-consuming scope of shortcuts.
Functions§
- shortcut
- Parse a shortcut string like
"Ctrl+S","F2","Alt+Shift+X".
Type Aliases§
- Shortcut
Map - Maps
Shortcut → C(an app-defined command value).