KeyGesture
struct · ferroui-base · v0.5.0
struct KeyGesture
Defines a keyboard input combination.
Members
new
const fn new(key: Key, modifiers: KeyModifiers) -> Self
Creates a gesture for a key with modifiers.
from_key
const fn from_key(key: Key) -> Self
Creates a gesture for a key without modifiers.
key
const fn key(self: &Self) -> Key
The key of the gesture.
key_modifiers
const fn key_modifiers(self: &Self) -> KeyModifiers
The modifier keys of the gesture.
parse
fn parse(gesture: &str) -> Result<KeyGesture, ParseKeyModifiersError>
Parses a gesture such as Ctrl+Shift+A.
Parts are separated by +. The last part that names a key decides
the key (+, -, . and , name the corresponding OEM keys);
every other part must be a modifier: Ctrl/Control, Shift,
Alt, Meta/Cmd/Win/⌘.
matches
fn matches(self: &Self, key_event: Option<&KeyEventArgs>) -> bool
Whether a key event matches the gesture: same modifiers and the same key, where the numpad operation keys match their regular counterparts.
to_platform_string
fn to_platform_string(self: &Self, format_provider: Option<Rc<KeyGestureFormatInfo>>) -> String
Formats the gesture with the platform's names for keys and
modifiers (the p format): the given format info, or the one
registered with the locator, or the invariant one.
to_string_format
fn to_string_format(self: &Self, format: Option<&str>, format_provider: Option<Rc<KeyGestureFormatInfo>>) -> Result<String, FormatError>
Returns the gesture as a string formatted according to the format string and the format provider.
The format is None, an empty string or "g" for the invariant format, or "p"
for the platform specific format: the given format info, or the one registered with
the locator, or the invariant one.
Fails with a FormatError if the format string is anything else.
format_with
fn format_with(self: &Self, format_info: &KeyGestureFormatInfo) -> String
Formats the gesture with the given format info.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeResourceKeyObjectPropertyValueAnyValueClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedToStringErasedDestructorIntoEitherCloneCopyDebugStructuralPartialEqPartialEqEqHashFromStrDisplayMarkupTypedValueTypeRegistration
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.