macro_rules! shortcut {
(Super) => { ... };
(Shift) => { ... };
(Ctrl) => { ... };
(Alt) => { ... };
($Key:tt) => { ... };
($($MODIFIER:ident)|+ + $Key:tt) => { ... };
($StarterKey:tt, $ComplementKey:tt) => { ... };
($StarterKey:tt, $($COMPLEMENT_MODIFIER:ident)|+ + $ComplementKey:tt) => { ... };
($($STARTER_MODIFIER:ident)|+ + $StarterKey:tt, $ComplementKey:tt) => { ... };
($($STARTER_MODIFIER:ident)|+ + $StarterKey:tt, $($COMPLEMENT_MODIFIER:ident)|+ + $ComplementKey:tt) => { ... };
}Expand description
Creates a Shortcut.
This macro input can be:
- A single
ModifierGesturevariant defines aShortcut::Modifier. - A single
Keyvariant defines aShortcut::Gesturewithout modifiers. - A single
charliteral that translates to aKey::Char. ModifiersStatefollowed by+followed by aKeyorchardefines a gesture with modifiers. Modifier combinations must be joined by|.- A gesture followed by
,followed by another gesture defines aShortcut::Chord.
Note that not all shortcuts can be declared with this macro, in particular there is no support for Key::Str
and KeyCode, these shortcuts must be declared manually. Also note that some keys are not recommended in shortcuts,
in particular Key::is_modifier and Key::is_composition keys will not work right.
ยงExamples
use zng_app::shortcut::{Shortcut, shortcut};
fn single_key() -> Shortcut {
shortcut!(Enter)
}
fn modified_key() -> Shortcut {
shortcut!(CTRL + 'C')
}
fn multi_modified_key() -> Shortcut {
shortcut!(CTRL | SHIFT + 'C')
}
fn chord() -> Shortcut {
shortcut!(CTRL + 'E', 'A')
}
fn modifier_release() -> Shortcut {
shortcut!(Alt)
}