pub trait EguiModifiersExt: Sealed {
// Required method
fn to_modifiers(&self) -> Vec<Modifier>;
}Expand description
Convert egui::Modifiers to a sorted Vec<Modifier>.
Egui’s mac_cmd and command fields are platform-dependent
abstractions. On non-macOS platforms, command mirrors ctrl.
This implementation maps ctrl, shift, alt, and either
mac_cmd or command (whichever represents the platform’s
command key) to kbd modifiers.
To avoid double-counting on macOS (where command == mac_cmd),
we use ctrl and mac_cmd as the canonical sources:
ctrl→Modifier::Ctrlshift→Modifier::Shiftalt→Modifier::Altmac_cmd→Modifier::Super
This trait is sealed and cannot be implemented outside this crate.
Required Methods§
Sourcefn to_modifiers(&self) -> Vec<Modifier>
fn to_modifiers(&self) -> Vec<Modifier>
Convert these egui modifiers to a Vec<Modifier>.
§Examples
use egui::Modifiers;
use kbd::prelude::*;
use kbd_egui::EguiModifiersExt;
let mods = Modifiers {
alt: false, ctrl: true, shift: true,
mac_cmd: false, command: false,
};
assert_eq!(mods.to_modifiers(), vec![Modifier::Ctrl, Modifier::Shift]);