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

The Mac ⌘ Command key

On Mac: ⌘ Command key, elsewhere: Ctrl key

Is shift the only pressed button?

true if only Self::ctrl or only Self::mac_cmd is pressed.

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

Trait Implementations

The resulting type after applying the | operator.
Performs the | operation. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.