pub struct Shortcut {
pub modifiers: Vec<Modifier>,
pub key: Key,
}Expand description
Represents a parsed keyboard shortcut
Fields§
§modifiers: Vec<Modifier>Modifier keys in the shortcut
key: KeyThe main key in the shortcut
Implementations§
Source§impl Shortcut
impl Shortcut
Sourcepub fn new(modifiers: Vec<Modifier>, key: Key) -> Self
pub fn new(modifiers: Vec<Modifier>, key: Key) -> Self
Create a new shortcut
Examples found in repository?
examples/gui_shortcuts.rs (line 98)
89 fn get_command(&self, modifier_vks: &[usize], key_vk: usize) -> Option<AppCommand> {
90 // 转换修饰键
91 let modifiers: Vec<Modifier> = modifier_vks
92 .iter()
93 .filter_map(|&code| Modifier::from_code(code, self.platform))
94 .collect();
95
96 // 转换主键
97 if let Some(key) = Key::from_code(key_vk, self.platform) {
98 let shortcut = Shortcut::new(modifiers, key);
99 return self.shortcuts.get(&shortcut).copied();
100 }
101
102 None
103 }Trait Implementations§
impl Eq for Shortcut
impl StructuralPartialEq for Shortcut
Auto Trait Implementations§
impl Freeze for Shortcut
impl RefUnwindSafe for Shortcut
impl Send for Shortcut
impl Sync for Shortcut
impl Unpin for Shortcut
impl UnwindSafe for Shortcut
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
Mutably borrows from an owned value. Read more