Struct me3_framework::overlay::Modifiers
source · [−]pub struct Modifiers {
pub alt: bool,
pub ctrl: bool,
pub shift: bool,
pub mac_cmd: bool,
pub command: bool,
}
Expand description
State of the modifier keys. These must be fed to egui.
The best way to compare Modifiers
is by using Modifiers::matches
.
Fields
alt: bool
Either of the alt keys are down (option ⌥ on Mac).
ctrl: bool
Either of the control keys are down.
When checking for keyboard shortcuts, consider using Self::command
instead.
shift: bool
Either of the shift keys are down.
mac_cmd: bool
The Mac ⌘ Command key. Should always be set to false
on other platforms.
command: bool
On Windows and Linux, set this to the same value as ctrl
.
On Mac, this should be set whenever one of the ⌘ Command keys are down (same as mac_cmd
).
This is so that egui can, for instance, select all text by checking for command + A
and it will work on both Mac and Windows.
Implementations
sourceimpl Modifiers
impl Modifiers
pub fn new() -> Modifiers
pub const NONE: Modifiers = Self{ alt: false, ctrl: false, shift: false, mac_cmd: false, command: false,}
pub const ALT: Modifiers = Self{ alt: true, ctrl: false, shift: false, mac_cmd: false, command: false,}
pub const CTRL: Modifiers = Self{ alt: false, ctrl: true, shift: false, mac_cmd: false, command: false,}
pub const SHIFT: Modifiers = Self{ alt: false, ctrl: false, shift: true, mac_cmd: false, command: false,}
pub const ALT_SHIFT: Modifiers = Self{ alt: true, ctrl: false, shift: true, mac_cmd: false, command: false,}
sourcepub const MAC_CMD: Modifiers = Self{
alt: false,
ctrl: false,
shift: false,
mac_cmd: true,
command: false,}
pub const MAC_CMD: Modifiers = Self{ alt: false, ctrl: false, shift: false, mac_cmd: true, command: false,}
The Mac ⌘ Command key
sourcepub const COMMAND: Modifiers = Self{
alt: false,
ctrl: false,
shift: false,
mac_cmd: false,
command: true,}
pub const COMMAND: Modifiers = Self{ alt: false, ctrl: false, shift: false, mac_cmd: false, command: true,}
On Mac: ⌘ Command key, elsewhere: Ctrl key
pub fn is_none(&self) -> bool
pub fn any(&self) -> bool
sourcepub fn shift_only(&self) -> bool
pub fn shift_only(&self) -> bool
Is shift the only pressed button?
sourcepub fn command_only(&self) -> bool
pub fn command_only(&self) -> bool
true if only Self::ctrl
or only Self::mac_cmd
is pressed.
sourcepub fn matches(&self, pattern: Modifiers) -> bool
pub fn matches(&self, pattern: Modifiers) -> bool
Check for equality but with proper handling of Self::command
.
assert!(Modifiers::CTRL.matches(Modifiers::CTRL));
assert!(!Modifiers::CTRL.matches(Modifiers::CTRL | Modifiers::SHIFT));
assert!(!(Modifiers::CTRL | Modifiers::SHIFT).matches(Modifiers::CTRL));
assert!((Modifiers::CTRL | Modifiers::COMMAND).matches(Modifiers::CTRL));
assert!((Modifiers::CTRL | Modifiers::COMMAND).matches(Modifiers::COMMAND));
assert!((Modifiers::MAC_CMD | Modifiers::COMMAND).matches(Modifiers::COMMAND));
assert!(!Modifiers::COMMAND.matches(Modifiers::MAC_CMD));