pub enum MouseButton {
Primary,
Secondary,
Middle,
Other(u8),
}Expand description
Which button a press came from — driver-facing rather than shaped after any one windowing library, so every driver maps its own vocabulary onto this one.
Only MouseButton::Primary drives the pointer model: it presses,
drags, places the caret and produces on_click. A
MouseButton::Secondary press asks the node under it for a context
menu (NodeSpec::on_context_menu) and touches nothing else — not
focus, not the caret, not a scrollbar thumb — because a right-click on
a selection has to leave that selection alone. Every non-primary
button, the secondary one included, reaches a node that claims it with
NodeSpec::on_button: its press, the motion while it is
held and its release, captured by that node; a claimed secondary press
is that node’s instead of a context menu. A non-primary press moves no
focus, caret, selection or scrollbar either way.
Variants§
Primary
The button that clicks and drags. The OS has already applied a left-handed swap, so this is not necessarily the left one.
Secondary
The context-menu button.
Middle
Other(u8)
A button this vocabulary does not name (back, forward, thumb buttons), by driver index.
Implementations§
Source§impl MouseButton
impl MouseButton
Sourcepub const NAMED: [MouseButton; 3]
pub const NAMED: [MouseButton; 3]
The three buttons that have a name, in code order. Other has no
name: a binding that needs one takes a MouseButton::code.
Sourcepub fn code(self) -> u32
pub fn code(self) -> u32
The number bindings pass buttons as: 0 primary, 1 secondary,
2 middle, 3 + n for Other(n).
Sourcepub fn from_code(code: u32) -> MouseButton
pub fn from_code(code: u32) -> MouseButton
Inverse of MouseButton::code; anything past the named three is
an Other, saturating rather than wrapping.
Sourcepub fn name(self) -> Option<&'static str>
pub fn name(self) -> Option<&'static str>
The wire name of a named button ("primary", "secondary",
"middle"); None for an Other.
Sourcepub fn from_name(name: &str) -> Option<MouseButton>
pub fn from_name(name: &str) -> Option<MouseButton>
The three named buttons by name, for bindings that spell them as
strings: the inverse of Self::name.
Sourcepub fn to_value(self) -> Value
pub fn to_value(self) -> Value
The value a button event carries for this button: its name for a
named one, its MouseButton::code for an
Other.
Trait Implementations§
Source§impl Clone for MouseButton
impl Clone for MouseButton
Source§fn clone(&self) -> MouseButton
fn clone(&self) -> MouseButton
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 MouseButton
Source§impl Debug for MouseButton
impl Debug for MouseButton
Source§impl Default for MouseButton
impl Default for MouseButton
Source§fn default() -> MouseButton
fn default() -> MouseButton
impl Eq for MouseButton
Source§impl PartialEq for MouseButton
impl PartialEq for MouseButton
impl StructuralPartialEq for MouseButton
Auto Trait Implementations§
impl Freeze for MouseButton
impl RefUnwindSafe for MouseButton
impl Send for MouseButton
impl Sync for MouseButton
impl Unpin for MouseButton
impl UnsafeUnpin for MouseButton
impl UnwindSafe for MouseButton
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,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.