pub struct Chord {
pub key: Key,
pub mods: Modifiers,
}Expand description
The keyboard vocabulary app code names: a Chord bound with shortcuts
in a ShortcutScope, the ShortcutHint a palette lists
(RenderRoot::shortcut_hints, labels rendered with Chord::display), the
FocusRingPolicy deciding when a Tab-focused control shows its ring, and
the OverlayKeys class that makes a floated surface modal for keys. Lifted
flat for EditCommand’s reason.
A key plus the exact modifier set it must be pressed with.
Fields§
§key: KeyA character key is stored lowercased and matched case-insensitively.
mods: ModifiersImplementations§
Source§impl Chord
impl Chord
Sourcepub fn new(key: Key, mods: Modifiers) -> Chord
pub fn new(key: Key, mods: Modifiers) -> Chord
A chord from its parts; a character key is lowercased so it matches either case, and a
Shift-insensitive symbol key (see Chord::matches) drops mods.shift.
Sourcepub fn parse(spec: &str) -> Result<Chord, ChordParseError>
pub fn parse(spec: &str) -> Result<Chord, ChordParseError>
Parse "Mod+K", "Shift+Tab", "Ctrl+Shift+P", "1", "F2": +-separated, case-insensitive
modifiers then one key. Mod is Command on macOS/iOS and Ctrl elsewhere, chosen at compile
time, so a web build running on a Mac maps it to Ctrl. A symbol key (+, ?, !) ignores
Shift, so "Shift+?" parses as "?"; spell Shift+1 as !.
Sourcepub fn matches(&self, event: &KeyEvent) -> bool
pub fn matches(&self, event: &KeyEvent) -> bool
Whether event presses this chord: the same key (characters case-insensitively) and
exactly the same modifiers. A symbol key (a character that is neither alphanumeric nor
whitespace) ignores event.modifiers.shift, because shells report Shift for the keys
that need it; ctrl, alt and meta still compare. An auto-repeat matches like a fresh press.
Trait Implementations§
impl Eq for Chord
impl StructuralPartialEq for Chord
Auto Trait Implementations§
impl Freeze for Chord
impl RefUnwindSafe for Chord
impl Send for Chord
impl Sync for Chord
impl Unpin for Chord
impl UnsafeUnpin for Chord
impl UnwindSafe for Chord
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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>
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)
&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)
&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> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.