SingleActivator class
A shortcut key combination of a single key and modifiers.
The 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 trigger key.
- If control is true, then at least one control key must be held. Otherwise, no control keys must be held.
- Similar conditions apply for the alt, shift, and meta keys.
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. For example, pressing key X while holding
ControlLeft and key A will be accepted by
SingleActivator(LogicalKeyboardKey.keyX, control: true)
. - SingleActivators do not consider modifiers to be a trigger key. For
example, pressing ControlLeft while holding key X will not activate a
SingleActivator(LogicalKeyboardKey.keyX, control: true)
.
See also:
- CharacterActivator, an activator that represents key combinations that result in the specified character, such as question mark.
- Implemented types
- Mixed-in types
Constructors
- SingleActivator(LogicalKeyboardKey trigger, {bool control = false, bool shift = false, bool alt = false, bool meta = false, LockState numLock = LockState.ignored, bool includeRepeats = true})
-
Triggered when the
trigger
key is pressed while the modifiers are held.const
Properties
- alt → bool
-
Whether either (or both) alt keys should be held for trigger to
activate the shortcut.
final
- control → bool
-
Whether either (or both) control keys should be held for trigger to
activate the shortcut.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- includeRepeats → bool
-
Whether this activator accepts repeat events of the trigger key.
final
- meta → bool
-
Whether either (or both) meta keys should be held for trigger to
activate the shortcut.
final
- numLock → LockState
-
Whether the NumLock key state should be checked for trigger to activate
the shortcut.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shift → bool
-
Whether either (or both) shift keys should be held for trigger to
activate the shortcut.
final
- trigger → LogicalKeyboardKey
-
The non-modifier key of the shortcut that is pressed after all modifiers
to activate the shortcut.
final
-
triggers
→ Iterable<
LogicalKeyboardKey> -
An optional property to provide all the keys that might be the final event
to trigger this shortcut.
no setteroverride
Methods
-
accepts(
KeyEvent event, HardwareKeyboard state) → bool -
Whether the triggering
event
and the keyboardstate
at the time of the event meet required conditions, providing that the event is a triggering event.override -
debugDescribeKeys(
) → String -
Returns a short and readable description of the key combination.
override
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
serializeForMenu(
) → ShortcutSerialization -
Implement this in a ShortcutActivator subclass to allow it to be
serialized for use in a PlatformMenuBar.
override
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringShort(
) → String -
A brief description of this object, usually just the runtimeType and the
hashCode.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited