pub struct MouseEvent {
pub location: MouseLocation,
pub wheel_delta_v: Option<WheelDelta>,
pub wheel_delta_h: Option<WheelDelta>,
pub is_precision_scroll: Option<PrecisionScroll>,
pub phase: MousePhase,
pub affected_buttons: HashSet<MouseButton>,
pub pressed_buttons: HashSet<MouseButton>,
}
Expand description
A MouseEvent
represents a pointer event with a specified phase, and the buttons
involved in said phase. The supported phases for mice include Up, Down, and Move.
§Example
The following MouseEvent represents a relative movement of 40 units in the x axis and 20 units in the y axis while holding the primary button (1) down.
let mouse_device_event = input_device::InputDeviceEvent::Mouse(MouseEvent::new(
MouseLocation::Relative(RelativePosition {
millimeters: Position { x: 4.0, y: 2.0 },
}),
Some(1),
Some(1),
MousePhase::Move,
HashSet::from_iter(vec![1]).into_iter()),
HashSet::from_iter(vec![1]).into_iter()),,
));
Fields§
§location: MouseLocation
The mouse location.
wheel_delta_v: Option<WheelDelta>
The mouse wheel rotated delta in vertical.
wheel_delta_h: Option<WheelDelta>
The mouse wheel rotated delta in horizontal.
is_precision_scroll: Option<PrecisionScroll>
The mouse device reports precision scroll delta.
phase: MousePhase
The phase of the [buttons
] associated with this input event.
The buttons relevant to this event.
The complete button state including this event.
Implementations§
Source§impl MouseEvent
impl MouseEvent
Sourcepub fn new(
location: MouseLocation,
wheel_delta_v: Option<WheelDelta>,
wheel_delta_h: Option<WheelDelta>,
phase: MousePhase,
affected_buttons: HashSet<MouseButton>,
pressed_buttons: HashSet<MouseButton>,
is_precision_scroll: Option<PrecisionScroll>,
) -> MouseEvent
pub fn new( location: MouseLocation, wheel_delta_v: Option<WheelDelta>, wheel_delta_h: Option<WheelDelta>, phase: MousePhase, affected_buttons: HashSet<MouseButton>, pressed_buttons: HashSet<MouseButton>, is_precision_scroll: Option<PrecisionScroll>, ) -> MouseEvent
Creates a new MouseEvent
.
§Parameters
location
: The mouse location.phase
: The phase of the [buttons
] associated with this input event.buttons
: The buttons relevant to this event.
pub fn record_inspect(&self, node: &Node)
Trait Implementations§
Source§impl Clone for MouseEvent
impl Clone for MouseEvent
Source§fn clone(&self) -> MouseEvent
fn clone(&self) -> MouseEvent
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for MouseEvent
impl Debug for MouseEvent
Source§impl PartialEq for MouseEvent
impl PartialEq for MouseEvent
impl StructuralPartialEq for MouseEvent
Auto Trait Implementations§
impl Freeze for MouseEvent
impl RefUnwindSafe for MouseEvent
impl Send for MouseEvent
impl Sync for MouseEvent
impl Unpin for MouseEvent
impl UnwindSafe for MouseEvent
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)