pub trait InputBinding {
// Required methods
fn matches(&self, ctx: &Context) -> bool;
fn consume(&self, ctx: &Context) -> bool;
fn display(&self) -> String;
fn as_keyboard_shortcut(&self) -> Option<KeyboardShortcut>;
}Expand description
Abstraction over different types of input bindings.
This trait allows treating static KeyboardShortcut constants and
dynamic DynamicShortcut values uniformly.
Required Methods§
Sourcefn matches(&self, ctx: &Context) -> bool
fn matches(&self, ctx: &Context) -> bool
Check if this binding was triggered (does not consume the input).
Sourcefn consume(&self, ctx: &Context) -> bool
fn consume(&self, ctx: &Context) -> bool
Consume the input and return whether it was triggered.
Once consumed, the shortcut won’t trigger other handlers.
Sourcefn display(&self) -> String
fn display(&self) -> String
Get a human-readable representation of this binding.
Useful for displaying in menus or help screens. Example: “⌘S” or “Ctrl+S”
Sourcefn as_keyboard_shortcut(&self) -> Option<KeyboardShortcut>
fn as_keyboard_shortcut(&self) -> Option<KeyboardShortcut>
Convert to KeyboardShortcut if possible.