Skip to main content

Modifiers

Struct Modifiers 

Source
pub struct Modifiers(/* private fields */);
Expand description

The keyboard modifiers held at an interaction: what a KeyEvent carries and what day::modifiers() answers ambiently (Toolkit::modifiers). A small set with a method per key: event.modifiers.shift(), Modifiers::PRIMARY | Modifiers::SHIFT. Touch-only backends answer Modifiers::NONE.

Modifiers::bits is the mask a backend’s numeric wire carries (bridge::BridgeKind::Key), and Modifiers::from_bits reads it back.

Implementations§

Source§

impl Modifiers

Source

pub const NONE: Modifiers

No modifier held.

Source

pub const SHIFT: Modifiers

Shift.

Source

pub const PRIMARY: Modifiers

The platform’s command key: ⌘ on Apple platforms, Ctrl elsewhere (the Shortcut::primary convention).

Source

pub const ALT: Modifiers

Alt (Option on Apple platforms).

Source

pub const CONTROL: Modifiers

The Control key itself, wherever it sits: on Apple platforms it is a different key from Modifiers::PRIMARY (⌘), elsewhere the same one, so a Ctrl+C on Linux sets both. Carried by key events on the full route (Decorate::keyboard).

Source

pub const fn bits(self) -> u8

The wire mask: one bit per modifier, in declaration order from bit 0.

Source

pub const fn from_bits(bits: u8) -> Modifiers

The set a wire mask spells; bits above the four modifiers are ignored.

Source

pub const fn is_empty(self) -> bool

Whether no modifier is held.

Source

pub const fn contains(self, other: Modifiers) -> bool

Whether every modifier in other is held.

Source

pub const fn with(self, other: Modifiers, held: bool) -> Modifiers

This set with other added when held: how a backend builds the set from the platform’s own flags (Modifiers::NONE.with(Modifiers::SHIFT, flags.shift)).

Source

pub const fn shift(self) -> bool

Whether Shift is held.

Source

pub const fn primary(self) -> bool

Whether the platform’s command key is held.

Source

pub const fn alt(self) -> bool

Whether Alt (Option) is held.

Source

pub const fn control(self) -> bool

Whether the Control key itself is held.

Trait Implementations§

Source§

impl BitOr for Modifiers

Source§

type Output = Modifiers

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Modifiers) -> Modifiers

Performs the | operation. Read more
Source§

impl BitOrAssign for Modifiers

Source§

fn bitor_assign(&mut self, rhs: Modifiers)

Performs the |= operation. Read more
Source§

impl Clone for Modifiers

Source§

fn clone(&self) -> Modifiers

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 Modifiers

Source§

impl Debug for Modifiers

Source§

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

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

impl Default for Modifiers

Source§

fn default() -> Modifiers

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

impl Eq for Modifiers

Source§

impl From<u8> for Modifiers

A wire mask (Modifiers::from_bits): what a backend’s key trampoline holds.

Source§

fn from(bits: u8) -> Modifiers

Converts to this type from the input type.
Source§

impl Hash for Modifiers

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Modifiers

Source§

fn eq(&self, other: &Modifiers) -> 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 Modifiers

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> AnyEq for T
where T: Any + PartialEq,

Source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

Source§

fn as_any(&self) -> &(dyn Any + 'static)

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<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> ErasedDestructor for T
where T: 'static,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoReactive<T, StaticMark> for T
where T: Clone + 'static,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.