pub struct KeyModifiers(/* private fields */);Expand description
Keyboard modifier flags.
Implemented as a manual bitflag over u8 (SHIFT = 1, CONTROL = 2, ALT = 4,
SUPER = 8) rather than a bitflags-generated type, so
this stays a plain value type with no macro-generated API surface. Combine with |.
Implementations§
Source§impl KeyModifiers
impl KeyModifiers
Sourcepub const NONE: KeyModifiers
pub const NONE: KeyModifiers
No modifiers.
Sourcepub const SHIFT: KeyModifiers
pub const SHIFT: KeyModifiers
Shift key.
Sourcepub const CONTROL: KeyModifiers
pub const CONTROL: KeyModifiers
Control key.
Sourcepub const ALT: KeyModifiers
pub const ALT: KeyModifiers
Alt key.
Sourcepub const SUPER: KeyModifiers
pub const SUPER: KeyModifiers
Super/Meta key (macOS Cmd, Windows/Super key).
Sourcepub const fn from_bits_truncate(bits: u8) -> KeyModifiers
pub const fn from_bits_truncate(bits: u8) -> KeyModifiers
Builds modifiers from a raw bitmask, silently ignoring any bits above SUPER (0b1111).
Bitmask layout: SHIFT = 1, CONTROL = 2, ALT = 4, SUPER = 8. This is the wire format
shared by backends that encode modifiers as a single byte (for example the WASM backend’s
JS/Rust boundary).
Sourcepub const fn from_parts(
shift: bool,
control: bool,
alt: bool,
super_: bool,
) -> KeyModifiers
pub const fn from_parts( shift: bool, control: bool, alt: bool, super_: bool, ) -> KeyModifiers
Builds modifiers from four independent flags, one per platform modifier key.
Naming all four as separate parameters (rather than taking a platform-specific modifiers type) makes the modifier set exhaustive by function signature: a backend that gains a fifth modifier fails to compile at every call site instead of silently dropping it.
Sourcepub const fn bits(self) -> u8
pub const fn bits(self) -> u8
Returns the raw bitmask, in the same layout from_bits_truncate
accepts. Only the low four bits are ever set.
Sourcepub const fn contains(self, other: KeyModifiers) -> bool
pub const fn contains(self, other: KeyModifiers) -> bool
Returns true if all bits in other are set in self.
Trait Implementations§
Source§impl BitAnd for KeyModifiers
impl BitAnd for KeyModifiers
Source§type Output = KeyModifiers
type Output = KeyModifiers
& operator.Source§fn bitand(self, rhs: KeyModifiers) -> KeyModifiers
fn bitand(self, rhs: KeyModifiers) -> KeyModifiers
& operation. Read moreSource§impl BitAndAssign for KeyModifiers
impl BitAndAssign for KeyModifiers
Source§fn bitand_assign(&mut self, rhs: KeyModifiers)
fn bitand_assign(&mut self, rhs: KeyModifiers)
&= operation. Read moreSource§impl BitOr for KeyModifiers
impl BitOr for KeyModifiers
Source§type Output = KeyModifiers
type Output = KeyModifiers
| operator.Source§fn bitor(self, rhs: KeyModifiers) -> KeyModifiers
fn bitor(self, rhs: KeyModifiers) -> KeyModifiers
| operation. Read moreSource§impl BitOrAssign for KeyModifiers
impl BitOrAssign for KeyModifiers
Source§fn bitor_assign(&mut self, rhs: KeyModifiers)
fn bitor_assign(&mut self, rhs: KeyModifiers)
|= operation. Read moreSource§impl Clone for KeyModifiers
impl Clone for KeyModifiers
Source§fn clone(&self) -> KeyModifiers
fn clone(&self) -> KeyModifiers
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for KeyModifiers
Source§impl Debug for KeyModifiers
impl Debug for KeyModifiers
Source§impl Default for KeyModifiers
impl Default for KeyModifiers
Source§fn default() -> KeyModifiers
fn default() -> KeyModifiers
Source§impl<'de> Deserialize<'de> for KeyModifiers
impl<'de> Deserialize<'de> for KeyModifiers
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<KeyModifiers, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<KeyModifiers, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for KeyModifiers
Source§impl Hash for KeyModifiers
impl Hash for KeyModifiers
Source§impl Not for KeyModifiers
impl Not for KeyModifiers
Source§type Output = KeyModifiers
type Output = KeyModifiers
! operator.Source§fn not(self) -> KeyModifiers
fn not(self) -> KeyModifiers
! operation. Read moreSource§impl PartialEq for KeyModifiers
impl PartialEq for KeyModifiers
Source§fn eq(&self, other: &KeyModifiers) -> bool
fn eq(&self, other: &KeyModifiers) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for KeyModifiers
impl Serialize for KeyModifiers
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for KeyModifiers
Auto Trait Implementations§
impl Freeze for KeyModifiers
impl RefUnwindSafe for KeyModifiers
impl Send for KeyModifiers
impl Sync for KeyModifiers
impl Unpin for KeyModifiers
impl UnsafeUnpin for KeyModifiers
impl UnwindSafe for KeyModifiers
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> WasmNotSend for Twhere
T: Send,
impl<T> WasmNotSendSync for Twhere
T: WasmNotSend + WasmNotSync,
impl<T> WasmNotSync for Twhere
T: Sync,
§impl<C> WithAlpha for Cwhere
C: Copy,
impl<C> WithAlpha for Cwhere
C: Copy,
§fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
self with alpha, storing alpha before the color in memory
(see [AlphaFirst]).§fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
self with alpha, storing alpha after the color in memory
(see [AlphaLast]).