pub enum MouseButton {
Left,
Middle,
Right,
WheelUp,
WheelDown,
WheelLeft,
WheelRight,
Back,
Forward,
Other(u8),
}Expand description
Which mouse button an event concerns. None on a MouseEvent means bare
motion with no button held.
Deliberately exhaustive (#843), and it is the case worth reading. The set is
already open at the data level — MouseButton::Other carries any code we do
not name — so the attribute would add nothing a caller could use. That is what
separates this type from Key, which has no catch-all: Char and F are
semantics, not escape hatches, so an unnamed key has nowhere to go and the
attribute is the only way to keep adding one cheap.
A second argument stood here and was withdrawn as false — that naming a
future Button8 would stop Other(8) being produced and break a consumer
matching on it. Three things are wrong with it, and the first is four lines
above: X11 buttons 8 and 9 are already named, as Back and Forward, and
Other is documented as 10+. The encoder then collapses the distinction
anyway — Some(Back) and Other(8) both emit 128 — and nothing outside this
crate matches a MouseButton we hand it, because nothing is ever handed one.
Left in view rather than deleted: a doc-comment whose own example contradicts
the enum beside it is worse than no comment, and this one shipped through a
completeness pass before a refuting one caught it.
Variants§
Left
Middle
Right
WheelUp
WheelDown
WheelLeft
Horizontal scroll / tilt-wheel — xterm buttons 6 and 7, encoded in the same 64-base wheel group as up/down.
WheelRight
Back
The thumb buttons — X11 buttons 8 and 9, the “back”/“forward” of the 128-base extra group.
Forward
Other(u8)
Any further mouse button by its X11 number (gaming-mouse side buttons, 10+). Encoded via the xterm bit formula; use the named variants above for buttons that have one.
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 more