pub struct CharacterActivator {
pub alt: bool,
pub control: bool,
pub meta: bool,
pub include_repeats: bool,
pub character: String,
}Expand description
A shortcut combination that is triggered by a key event that produces a specific character.
Keys often produce different characters when combined with modifiers. For example, it might be helpful for the user to bring up a help menu by pressing the question mark (‘?’). However, there is no logical key that directly represents a question mark. Although ‘Shift+Slash’ produces a ‘?’ character on a US keyboard, its logical key is still considered a Slash key, and hard-coding ‘Shift+Slash’ in this situation is unfriendly to other keyboard layouts.
For example, CharacterActivator::new("?") is triggered when a key combination results in a
question mark, which is ‘Shift+Slash’ on a US keyboard, but ‘Shift+Comma’ on a French
keyboard.
The alt, control, and meta flags represent
whether the respective modifier keys should be held (true) or released (false). They default
to false. CharacterActivator cannot check shifted keys, since the Shift key affects the
resulting character, and will accept whether either of the Shift keys are pressed or not, as
long as the key event produces the correct character.
See also:
SingleActivator, an activator that represents a single key combined with modifiers, such asCtrl+CorCtrl-Right Arrow.
Fields§
§alt: boolWhether either (or both) Alt keys should be held for the
character to activate the shortcut.
It defaults to false, meaning all Alt keys must be released when the event is received in order to activate the shortcut. If it’s true, then either one or both Alt keys must be pressed.
control: boolWhether either (or both) Control keys should be held for the
character to activate the shortcut.
It defaults to false, meaning all Control keys must be released when the event is received in order to activate the shortcut. If it’s true, then either one or both Control keys must be pressed.
meta: boolWhether either (or both) Meta keys should be held for the
character to activate the shortcut.
It defaults to false, meaning all Meta keys must be released when the event is received in order to activate the shortcut. If it’s true, then either one or both Meta keys must be pressed.
include_repeats: boolWhether this activator accepts repeat events of the character.
If include_repeats is true, the activator is checked on all
key down and key repeat events for the character. If it is false,
only the character events that are key down events will be
considered.
character: StringThe character which triggers the shortcut.
This is typically a single-character string, such as ‘?’ or ‘œ’, although
CharacterActivator doesn’t check the length of character or
whether it can be matched by any key combination at all. It is case-sensitive, since the
character is directly compared to the character reported by the
platform.
Implementations§
Source§impl CharacterActivator
impl CharacterActivator
Sourcepub fn new(character: impl Into<String>) -> CharacterActivator
pub fn new(character: impl Into<String>) -> CharacterActivator
Triggered when the key event yields the given character.
Sourcepub fn alt(self, alt: bool) -> CharacterActivator
pub fn alt(self, alt: bool) -> CharacterActivator
Dart CharacterActivator(alt:).
Sourcepub fn control(self, control: bool) -> CharacterActivator
pub fn control(self, control: bool) -> CharacterActivator
Dart CharacterActivator(control:).
Sourcepub fn meta(self, meta: bool) -> CharacterActivator
pub fn meta(self, meta: bool) -> CharacterActivator
Dart CharacterActivator(meta:).
Sourcepub fn include_repeats(self, include_repeats: bool) -> CharacterActivator
pub fn include_repeats(self, include_repeats: bool) -> CharacterActivator
Dart CharacterActivator(includeRepeats:).
Trait Implementations§
Source§impl Clone for CharacterActivator
impl Clone for CharacterActivator
Source§impl Debug for CharacterActivator
impl Debug for CharacterActivator
impl Eq for CharacterActivator
Source§impl MenuSerializableShortcut for CharacterActivator
impl MenuSerializableShortcut for CharacterActivator
ShortcutActivator implementor to allow it to be serialized for use
in a PlatformMenuBar.Source§impl PartialEq for CharacterActivator
impl PartialEq for CharacterActivator
Source§impl ShortcutActivator for CharacterActivator
impl ShortcutActivator for CharacterActivator
Source§fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
ShortcutActivator.debugFillProperties, from Diagnosticable: an activator
adds its own fields.Source§fn accepts(
&self,
app: &App,
event: &KeyEvent,
state: Handle<HardwareKeyboard>,
) -> bool
fn accepts( &self, app: &App, event: &KeyEvent, state: Handle<HardwareKeyboard>, ) -> bool
event and the keyboard state at the time of the event meet
required conditions, providing that the event is a triggering event. Read moreSource§fn debug_describe_keys(&self) -> String
fn debug_describe_keys(&self) -> String
Source§fn triggers(&self) -> Option<Vec<LogicalKeyboardKey>>
fn triggers(&self) -> Option<Vec<LogicalKeyboardKey>>
Source§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
ShortcutActivator.toStringShort: the type and the identity.Source§fn diagnostic_string(&self) -> String
fn diagnostic_string(&self) -> String
Diagnosticable.toString, which a shortcut map’s entries print.impl StructuralPartialEq for CharacterActivator
Auto Trait Implementations§
impl Forget for CharacterActivator
impl Freeze for CharacterActivator
impl Move for CharacterActivator
impl RefUnwindSafe for CharacterActivator
impl Send for CharacterActivatorwhere
RawVecInner: Send,
impl Sync for CharacterActivatorwhere
RawVecInner: Sync,
impl Unpin for CharacterActivator
impl UnsafeUnpin for CharacterActivator
impl UnwindSafe for CharacterActivatorwhere
RawVecInner: 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
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<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.