pub struct KeyBinding { /* private fields */ }Expand description
A keybinding and its associated metadata, from the keymap.
Implementations§
Source§impl KeyBinding
impl KeyBinding
Sourcepub fn new<A: Action>(
keystrokes: &str,
action: A,
context: Option<&str>,
) -> Self
pub fn new<A: Action>( keystrokes: &str, action: A, context: Option<&str>, ) -> Self
Construct a new keybinding from the given data. Panics on parse error.
Sourcepub fn load(
keystrokes: &str,
action: Box<dyn Action>,
context_predicate: Option<Rc<KeyBindingContextPredicate>>,
use_key_equivalents: bool,
action_input: Option<SharedString>,
keyboard_mapper: &dyn PlatformKeyboardMapper,
) -> Result<Self, InvalidKeystrokeError>
pub fn load( keystrokes: &str, action: Box<dyn Action>, context_predicate: Option<Rc<KeyBindingContextPredicate>>, use_key_equivalents: bool, action_input: Option<SharedString>, keyboard_mapper: &dyn PlatformKeyboardMapper, ) -> Result<Self, InvalidKeystrokeError>
Load a keybinding from the given raw data.
Sourcepub fn with_meta(self, meta: KeyBindingMetaIndex) -> Self
pub fn with_meta(self, meta: KeyBindingMetaIndex) -> Self
Set the metadata for this binding.
Sourcepub fn set_meta(&mut self, meta: KeyBindingMetaIndex)
pub fn set_meta(&mut self, meta: KeyBindingMetaIndex)
Set the metadata for this binding.
Sourcepub fn match_keystrokes(&self, typed: &[impl AsKeystroke]) -> Option<bool>
pub fn match_keystrokes(&self, typed: &[impl AsKeystroke]) -> Option<bool>
Check if the given keystrokes match this binding.
Sourcepub fn keystrokes(&self) -> &[KeybindingKeystroke]
pub fn keystrokes(&self) -> &[KeybindingKeystroke]
Get the keystrokes associated with this binding
Sourcepub fn predicate(&self) -> Option<Rc<KeyBindingContextPredicate>>
pub fn predicate(&self) -> Option<Rc<KeyBindingContextPredicate>>
Get the predicate used to match this binding
Sourcepub fn meta(&self) -> Option<KeyBindingMetaIndex>
pub fn meta(&self) -> Option<KeyBindingMetaIndex>
Get the metadata for this binding
Sourcepub fn action_input(&self) -> Option<SharedString>
pub fn action_input(&self) -> Option<SharedString>
Get the action input associated with the action for this binding
Trait Implementations§
Source§impl Clone for KeyBinding
impl Clone for KeyBinding
Auto Trait Implementations§
impl Freeze for KeyBinding
impl !RefUnwindSafe for KeyBinding
impl !Send for KeyBinding
impl !Sync for KeyBinding
impl Unpin for KeyBinding
impl !UnwindSafe for KeyBinding
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more