Macro zng_app::shortcut::shortcut

source ·
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:

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)
}