pub struct KeyMap<A> {
pub id: String,
pub bindings: HashMap<Vec<KeyChord>, A>,
}Fields§
§id: String§bindings: HashMap<Vec<KeyChord>, A>Implementations§
Source§impl<A> KeyMap<A>
impl<A> KeyMap<A>
pub fn new(id: impl Into<String>) -> Self
pub fn bind(&mut self, sequence: impl Into<Vec<KeyChord>>, action: A)
Sourcepub fn unbind(&mut self, sequence: &[KeyChord]) -> Option<A>
pub fn unbind(&mut self, sequence: &[KeyChord]) -> Option<A>
Remove the binding for an exact chord sequence, returning the action it
was mapped to (if any). Pair with crate::input::try_parse_binding to
drive a remap UI: map.unbind(&try_parse_binding(old)?).
Source§impl<A: PartialEq> KeyMap<A>
impl<A: PartialEq> KeyMap<A>
Sourcepub fn bindings_for(&self, action: &A) -> Vec<&[KeyChord]>
pub fn bindings_for(&self, action: &A) -> Vec<&[KeyChord]>
Every chord sequence currently bound to action in this map. Useful for
a help screen (“what fires this action?”) or to find what to unbind
before rebinding.
Sourcepub fn unbind_action(&mut self, action: &A) -> usize
pub fn unbind_action(&mut self, action: &A) -> usize
Remove every binding mapped to action, returning how many were
removed. Lets a remap UI clear an action’s old keys before assigning new
ones, regardless of how many sequences pointed at it.
Trait Implementations§
Auto Trait Implementations§
impl<A> Freeze for KeyMap<A>
impl<A> RefUnwindSafe for KeyMap<A>where
A: RefUnwindSafe,
impl<A> Send for KeyMap<A>where
A: Send,
impl<A> Sync for KeyMap<A>where
A: Sync,
impl<A> Unpin for KeyMap<A>where
A: Unpin,
impl<A> UnsafeUnpin for KeyMap<A>
impl<A> UnwindSafe for KeyMap<A>where
A: UnwindSafe,
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> 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