pub struct SingleActivator {
pub trigger: LogicalKeyboardKey,
pub control: bool,
pub shift: bool,
pub alt: bool,
pub meta: bool,
pub num_lock: LockState,
pub include_repeats: bool,
}Expand description
A shortcut key combination of a single key and modifiers.
SingleActivator implements typical shortcuts such as:
- ArrowLeft
- Shift + Delete
- Control + Alt + Meta + Shift + A
More specifically, it creates shortcut key combinations that are composed of a
trigger key, and zero, some, or all of the four modifiers (control,
shift, alt, meta). The shortcut is activated when the following conditions are met:
- The incoming event is a down event for a
triggerkey. - If
controlis true, then at least one control key must be held. Otherwise, no control keys must be held. - Similar conditions apply for the
alt,shift, andmetakeys.
This resembles the typical behavior of most operating systems, and handles modifier keys
differently from LogicalKeySet in the following way:
SingleActivators allow additional non-modifier keys being pressed in order to activate the shortcut.SingleActivators do not consider modifiers to be a trigger key.
See also:
CharacterActivator, an activator that represents key combinations that result in the specified character, such as question mark.
Fields§
§trigger: LogicalKeyboardKeyThe non-modifier key of the shortcut that is pressed after all modifiers to activate the shortcut.
For example, for Control + C, trigger should be
LogicalKeyboardKey::KEY_C.
control: boolWhether either (or both) control keys should be held for trigger 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 or both Control keys must be pressed.
shift: boolWhether either (or both) shift keys should be held for trigger to
activate the shortcut.
It defaults to false, meaning all Shift keys must be released when the event is received in order to activate the shortcut. If it’s true, then either or both Shift keys must be pressed.
alt: boolWhether either (or both) alt keys should be held for trigger 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 or both Alt keys must be pressed.
meta: boolWhether either (or both) meta keys should be held for trigger 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 or both Meta keys must be pressed.
num_lock: LockStateWhether the NumLock key state should be checked for trigger to
activate the shortcut.
It defaults to LockState::Ignored, meaning the NumLock state is ignored when the
event is received in order to activate the shortcut. If it’s LockState::Locked, then
the NumLock key must be locked. If it’s LockState::Unlocked, then the NumLock key
must be unlocked.
include_repeats: boolWhether this activator accepts repeat events of the trigger key.
If include_repeats is true, the activator is checked on all
key down or key repeat events for the trigger key. If it is false,
only trigger key events which are key down events will be considered.
Implementations§
Source§impl SingleActivator
impl SingleActivator
Sourcepub fn new(trigger: LogicalKeyboardKey) -> SingleActivator
pub fn new(trigger: LogicalKeyboardKey) -> SingleActivator
Sourcepub fn control(self, control: bool) -> SingleActivator
pub fn control(self, control: bool) -> SingleActivator
Dart SingleActivator(control:).
Sourcepub fn shift(self, shift: bool) -> SingleActivator
pub fn shift(self, shift: bool) -> SingleActivator
Dart SingleActivator(shift:).
Sourcepub fn alt(self, alt: bool) -> SingleActivator
pub fn alt(self, alt: bool) -> SingleActivator
Dart SingleActivator(alt:).
Sourcepub fn meta(self, meta: bool) -> SingleActivator
pub fn meta(self, meta: bool) -> SingleActivator
Dart SingleActivator(meta:).
Sourcepub fn num_lock(self, num_lock: LockState) -> SingleActivator
pub fn num_lock(self, num_lock: LockState) -> SingleActivator
Dart SingleActivator(numLock:).
Sourcepub fn include_repeats(self, include_repeats: bool) -> SingleActivator
pub fn include_repeats(self, include_repeats: bool) -> SingleActivator
Dart SingleActivator(includeRepeats:).
Trait Implementations§
Source§impl Clone for SingleActivator
impl Clone for SingleActivator
impl Copy for SingleActivator
Source§impl Debug for SingleActivator
impl Debug for SingleActivator
impl Eq for SingleActivator
Source§impl MenuSerializableShortcut for SingleActivator
impl MenuSerializableShortcut for SingleActivator
ShortcutActivator implementor to allow it to be serialized for use
in a PlatformMenuBar.Source§impl PartialEq for SingleActivator
impl PartialEq for SingleActivator
Source§impl ShortcutActivator for SingleActivator
impl ShortcutActivator for SingleActivator
Source§fn debug_describe_keys(&self) -> String
fn debug_describe_keys(&self) -> String
Returns a short and readable description of the key combination.
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 triggers(&self) -> Option<Vec<LogicalKeyboardKey>>
fn triggers(&self) -> Option<Vec<LogicalKeyboardKey>>
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 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 SingleActivator
Auto Trait Implementations§
impl Forget for SingleActivator
impl Freeze for SingleActivator
impl Move for SingleActivator
impl RefUnwindSafe for SingleActivator
impl Send for SingleActivator
impl Sync for SingleActivator
impl Unpin for SingleActivator
impl UnsafeUnpin for SingleActivator
impl UnwindSafe for SingleActivator
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.