pub struct MouseButton(/* private fields */);
Expand description
A u32
bit mask of all mouse buttons that were pressed
during a given mouse event.
This is a bit mask because it is possible for multiple buttons to be pressed simultaneously during a given input event.
Implementations§
Source§impl MouseButton
impl MouseButton
Sourcepub const PRIMARY: MouseButton
pub const PRIMARY: MouseButton
The primary mouse button, typically the left-click button.
Sourcepub const SECONDARY: MouseButton
pub const SECONDARY: MouseButton
The secondary mouse button, typically the right-click button.
Sourcepub const MIDDLE: MouseButton
pub const MIDDLE: MouseButton
The middle mouse button, typically the scroll-wheel click button.
Sourcepub const BACK: MouseButton
pub const BACK: MouseButton
The fourth mouse button, typically used for back navigation.
Sourcepub const FORWARD: MouseButton
pub const FORWARD: MouseButton
The fifth mouse button, typically used for forward navigation.
Source§impl MouseButton
impl MouseButton
Sourcepub const fn empty() -> MouseButton
pub const fn empty() -> MouseButton
Get a flags value with all bits unset.
Sourcepub const fn all() -> MouseButton
pub const fn all() -> MouseButton
Get a flags value with all known bits set.
Sourcepub const fn bits(&self) -> u32
pub const fn bits(&self) -> u32
Get the underlying bits value.
The returned value is exactly the bits set in this flags value.
Sourcepub const fn from_bits(bits: u32) -> Option<MouseButton>
pub const fn from_bits(bits: u32) -> Option<MouseButton>
Convert from a bits value.
This method will return None
if any unknown bits are set.
Sourcepub const fn from_bits_truncate(bits: u32) -> MouseButton
pub const fn from_bits_truncate(bits: u32) -> MouseButton
Convert from a bits value, unsetting any unknown bits.
Sourcepub const fn from_bits_retain(bits: u32) -> MouseButton
pub const fn from_bits_retain(bits: u32) -> MouseButton
Convert from a bits value exactly.
Sourcepub fn from_name(name: &str) -> Option<MouseButton>
pub fn from_name(name: &str) -> Option<MouseButton>
Get a flags value with the bits of a flag with the given name set.
This method will return None
if name
is empty or doesn’t
correspond to any named flag.
Sourcepub const fn intersects(&self, other: MouseButton) -> bool
pub const fn intersects(&self, other: MouseButton) -> bool
Whether any set bits in a source flags value are also set in a target flags value.
Sourcepub const fn contains(&self, other: MouseButton) -> bool
pub const fn contains(&self, other: MouseButton) -> bool
Whether all set bits in a source flags value are also set in a target flags value.
Sourcepub fn insert(&mut self, other: MouseButton)
pub fn insert(&mut self, other: MouseButton)
The bitwise or (|
) of the bits in two flags values.
Sourcepub fn remove(&mut self, other: MouseButton)
pub fn remove(&mut self, other: MouseButton)
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
remove
won’t truncate other
, but the !
operator will.
Sourcepub fn toggle(&mut self, other: MouseButton)
pub fn toggle(&mut self, other: MouseButton)
The bitwise exclusive-or (^
) of the bits in two flags values.
Sourcepub fn set(&mut self, other: MouseButton, value: bool)
pub fn set(&mut self, other: MouseButton, value: bool)
Call insert
when value
is true
or remove
when value
is false
.
Sourcepub const fn intersection(self, other: MouseButton) -> MouseButton
pub const fn intersection(self, other: MouseButton) -> MouseButton
The bitwise and (&
) of the bits in two flags values.
Sourcepub const fn union(self, other: MouseButton) -> MouseButton
pub const fn union(self, other: MouseButton) -> MouseButton
The bitwise or (|
) of the bits in two flags values.
Sourcepub const fn difference(self, other: MouseButton) -> MouseButton
pub const fn difference(self, other: MouseButton) -> MouseButton
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.
Sourcepub const fn symmetric_difference(self, other: MouseButton) -> MouseButton
pub const fn symmetric_difference(self, other: MouseButton) -> MouseButton
The bitwise exclusive-or (^
) of the bits in two flags values.
Sourcepub const fn complement(self) -> MouseButton
pub const fn complement(self) -> MouseButton
The bitwise negation (!
) of the bits in a flags value, truncating the result.
Source§impl MouseButton
impl MouseButton
Sourcepub const fn iter(&self) -> Iter<MouseButton>
pub const fn iter(&self) -> Iter<MouseButton>
Yield a set of contained flags values.
Each yielded flags value will correspond to a defined named flag. Any unknown bits will be yielded together as a final flags value.
Sourcepub const fn iter_names(&self) -> IterNames<MouseButton>
pub const fn iter_names(&self) -> IterNames<MouseButton>
Yield a set of contained named flags values.
This method is like iter
, except only yields bits in contained named flags.
Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
Source§impl MouseButton
impl MouseButton
Sourcepub fn is_primary(&self) -> bool
pub fn is_primary(&self) -> bool
Returns true if the primary mouse button is pressed.
Sourcepub fn is_secondary(&self) -> bool
pub fn is_secondary(&self) -> bool
Returns true if the secondary mouse button is pressed.
Sourcepub fn is_forward(&self) -> bool
pub fn is_forward(&self) -> bool
Returns true if the forward mouse button is pressed.
Returns true if the n
th button is pressed.
The button values are:
- n = 0: PRIMARY
- n = 1: SECONDARY
- n = 2: MIDDLE
- n = 3: BACK
- n = 4: FORWARD
- n > 4: other/custom
Returns a MouseButton
bit mask based on the raw button value: 1 << raw
.
A raw button value is a number that represents a mouse button, like so:
- 0: MouseButton::PRIMARY
- 1: MouseButton::SECONDARY
- 2: MouseButton::MIDDLE
- 3: MouseButton::BACK
- 4: MouseButton::FORWARD
- etc.
Trait Implementations§
Source§impl Binary for MouseButton
impl Binary for MouseButton
Source§impl BitAnd for MouseButton
impl BitAnd for MouseButton
Source§fn bitand(self, other: MouseButton) -> MouseButton
fn bitand(self, other: MouseButton) -> MouseButton
The bitwise and (&
) of the bits in two flags values.
Source§type Output = MouseButton
type Output = MouseButton
&
operator.Source§impl BitAndAssign for MouseButton
impl BitAndAssign for MouseButton
Source§fn bitand_assign(&mut self, other: MouseButton)
fn bitand_assign(&mut self, other: MouseButton)
The bitwise and (&
) of the bits in two flags values.
Source§impl BitOr for MouseButton
impl BitOr for MouseButton
Source§fn bitor(self, other: MouseButton) -> MouseButton
fn bitor(self, other: MouseButton) -> MouseButton
The bitwise or (|
) of the bits in two flags values.
Source§type Output = MouseButton
type Output = MouseButton
|
operator.Source§impl BitOrAssign for MouseButton
impl BitOrAssign for MouseButton
Source§fn bitor_assign(&mut self, other: MouseButton)
fn bitor_assign(&mut self, other: MouseButton)
The bitwise or (|
) of the bits in two flags values.
Source§impl BitXor for MouseButton
impl BitXor for MouseButton
Source§fn bitxor(self, other: MouseButton) -> MouseButton
fn bitxor(self, other: MouseButton) -> MouseButton
The bitwise exclusive-or (^
) of the bits in two flags values.
Source§type Output = MouseButton
type Output = MouseButton
^
operator.Source§impl BitXorAssign for MouseButton
impl BitXorAssign for MouseButton
Source§fn bitxor_assign(&mut self, other: MouseButton)
fn bitxor_assign(&mut self, other: MouseButton)
The bitwise exclusive-or (^
) of the bits in two flags values.
Source§impl Clone for MouseButton
impl Clone for MouseButton
Source§fn clone(&self) -> MouseButton
fn clone(&self) -> MouseButton
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for MouseButton
impl Debug for MouseButton
Source§impl Default for MouseButton
impl Default for MouseButton
Source§fn default() -> MouseButton
fn default() -> MouseButton
Source§impl Extend<MouseButton> for MouseButton
impl Extend<MouseButton> for MouseButton
Source§fn extend<T>(&mut self, iterator: T)where
T: IntoIterator<Item = MouseButton>,
fn extend<T>(&mut self, iterator: T)where
T: IntoIterator<Item = MouseButton>,
The bitwise or (|
) of the bits in each flags value.
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl Flags for MouseButton
impl Flags for MouseButton
Source§const FLAGS: &'static [Flag<MouseButton>]
const FLAGS: &'static [Flag<MouseButton>]
Source§fn from_bits_retain(bits: u32) -> MouseButton
fn from_bits_retain(bits: u32) -> MouseButton
Source§fn contains_unknown_bits(&self) -> bool
fn contains_unknown_bits(&self) -> bool
true
if any unknown bits are set.Source§fn from_bits_truncate(bits: Self::Bits) -> Self
fn from_bits_truncate(bits: Self::Bits) -> Self
Source§fn from_name(name: &str) -> Option<Self>
fn from_name(name: &str) -> Option<Self>
Source§fn iter_names(&self) -> IterNames<Self>
fn iter_names(&self) -> IterNames<Self>
Source§fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
Source§fn contains(&self, other: Self) -> boolwhere
Self: Sized,
fn contains(&self, other: Self) -> boolwhere
Self: Sized,
Source§fn insert(&mut self, other: Self)where
Self: Sized,
fn insert(&mut self, other: Self)where
Self: Sized,
|
) of the bits in two flags values.Source§fn remove(&mut self, other: Self)where
Self: Sized,
fn remove(&mut self, other: Self)where
Self: Sized,
&!
). Read moreSource§fn toggle(&mut self, other: Self)where
Self: Sized,
fn toggle(&mut self, other: Self)where
Self: Sized,
^
) of the bits in two flags values.Source§fn intersection(self, other: Self) -> Self
fn intersection(self, other: Self) -> Self
&
) of the bits in two flags values.Source§fn difference(self, other: Self) -> Self
fn difference(self, other: Self) -> Self
&!
). Read moreSource§fn symmetric_difference(self, other: Self) -> Self
fn symmetric_difference(self, other: Self) -> Self
^
) of the bits in two flags values.Source§fn complement(self) -> Self
fn complement(self) -> Self
!
) of the bits in a flags value, truncating the result.Source§impl FromIterator<MouseButton> for MouseButton
impl FromIterator<MouseButton> for MouseButton
Source§fn from_iter<T>(iterator: T) -> MouseButtonwhere
T: IntoIterator<Item = MouseButton>,
fn from_iter<T>(iterator: T) -> MouseButtonwhere
T: IntoIterator<Item = MouseButton>,
The bitwise or (|
) of the bits in each flags value.
Source§impl IntoIterator for MouseButton
impl IntoIterator for MouseButton
Source§type Item = MouseButton
type Item = MouseButton
Source§type IntoIter = Iter<MouseButton>
type IntoIter = Iter<MouseButton>
Source§fn into_iter(self) -> <MouseButton as IntoIterator>::IntoIter
fn into_iter(self) -> <MouseButton as IntoIterator>::IntoIter
Source§impl LowerHex for MouseButton
impl LowerHex for MouseButton
Source§impl Not for MouseButton
impl Not for MouseButton
Source§fn not(self) -> MouseButton
fn not(self) -> MouseButton
The bitwise negation (!
) of the bits in a flags value, truncating the result.
Source§type Output = MouseButton
type Output = MouseButton
!
operator.Source§impl Octal for MouseButton
impl Octal for MouseButton
Source§impl PartialEq for MouseButton
impl PartialEq for MouseButton
Source§impl Sub for MouseButton
impl Sub for MouseButton
Source§fn sub(self, other: MouseButton) -> MouseButton
fn sub(self, other: MouseButton) -> MouseButton
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.
Source§type Output = MouseButton
type Output = MouseButton
-
operator.Source§impl SubAssign for MouseButton
impl SubAssign for MouseButton
Source§fn sub_assign(&mut self, other: MouseButton)
fn sub_assign(&mut self, other: MouseButton)
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.