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: boolEither of the alt keys are down (option ⌥ on Mac).
ctrl: boolEither of the control keys are down.
When checking for keyboard shortcuts, consider using Self::command instead.
shift: boolEither of the shift keys are down.
mac_cmd: boolThe Mac ⌘ Command key. Should always be set to false on other platforms.
command: boolOn 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() -> Self
pub const NONE: Self
pub const ALT: Self
pub const CTRL: Self
pub const SHIFT: Self
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));Trait Implementations
sourceimpl<'de> Deserialize<'de> for Modifiers
impl<'de> Deserialize<'de> for Modifiers
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for Modifiers
impl StructuralPartialEq for Modifiers
Auto Trait Implementations
impl RefUnwindSafe for Modifiers
impl Send for Modifiers
impl Sync for Modifiers
impl Unpin for Modifiers
impl UnwindSafe for Modifiers
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more