Skip to main content

KeyMods

Struct KeyMods 

Source
pub struct KeyMods {
    pub shift: bool,
    pub ctrl: bool,
    pub alt: bool,
    pub super_key: bool,
}
Expand description

Physical modifier state. Unlike Mods — which abstracts platform conventions for the input widget (word, doc) — nothing here is normalized: an app binding Ctrl-w needs to know it was Control and not Command.

Fields§

§shift: bool§ctrl: bool§alt: bool§super_key: bool

Windows key / Command / Super.

Implementations§

Source§

impl KeyMods

Source

pub const SHIFT: u32

Bit 0 Shift, 1 Ctrl, 2 Alt, 3 Super — the order the fields are declared in, and the C header’s KUI_KMOD_* (pinned there). What a wire that carries the state as one integer spells it as: the conformance corpus’s modifiers step, the C input door.

Source

pub const CTRL: u32

Source

pub const ALT: u32

Source

pub const SUPER: u32

Source

pub const NONE: KeyMods

No modifier held: what the with_* steps start from — KeyMods::NONE.with_shift().with_ctrl().

Source

pub const fn with_shift(self) -> Self

Source

pub const fn with_ctrl(self) -> Self

Source

pub const fn with_alt(self) -> Self

Source

pub const fn with_super(self) -> Self

Source

pub const fn with_primary(self) -> Self

The platform primary shortcut modifier held: Command on macOS, Control elsewhere — the one Self::primary reads.

Source

pub fn from_bits(bits: u32) -> Self

Source

pub fn bits(self) -> u32

Source

pub fn any(self) -> bool

Source

pub fn any_of(self, other: KeyMods) -> bool

Whether any modifier of other is held here.

Source

pub fn parse(names: &str) -> Self

From the schema’s spelling (the scrollMods row): names separated by spaces or commas — "ctrl", "ctrl super", "shift, alt". A word that is none of the four is skipped, so a string of none of them names nothing.

Source

pub fn to_fields(self) -> Value

{shift=, ctrl=, alt=, super=}: the state as an event carries it under a field of its own (a scroll event’s mods).

Source

pub fn primary(self) -> bool

The platform primary shortcut modifier: Command on macOS, Control elsewhere.

Source

pub fn to_value(self) -> Value

The payload form of a modifier change: {kind="modifiers", shift=, ctrl=, alt=, super=}.

Trait Implementations§

Source§

impl Clone for KeyMods

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for KeyMods

Source§

impl Debug for KeyMods

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for KeyMods

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for KeyMods

Source§

impl PartialEq for KeyMods

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for KeyMods

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.