pub struct MouseData {
Show 14 fields pub alt_key: bool, pub button: i16, pub buttons: u16, pub client_x: i32, pub client_y: i32, pub ctrl_key: bool, pub meta_key: bool, pub offset_x: i32, pub offset_y: i32, pub page_x: i32, pub page_y: i32, pub screen_x: i32, pub screen_y: i32, pub shift_key: bool,
}
Expand description

A synthetic event that wraps a web-style MouseEvent Data associated with a mouse event

Do not use the deprecated fields; they may change or become private in the future.

Fields§

§alt_key: bool
👎Deprecated since 0.3.0: use modifiers() instead

True if the alt key was down when the mouse event was fired.

§button: i16
👎Deprecated since 0.3.0: use trigger_button() instead

The button number that was pressed (if applicable) when the mouse event was fired.

§buttons: u16
👎Deprecated since 0.3.0: use held_buttons() instead

Indicates which buttons are pressed on the mouse (or other input device) when a mouse event is triggered.

Each button that can be pressed is represented by a given number (see below). If more than one button is pressed, the button values are added together to produce a new number. For example, if the secondary (2) and auxiliary (4) buttons are pressed simultaneously, the value is 6 (i.e., 2 + 4).

  • 1: Primary button (usually the left button)
  • 2: Secondary button (usually the right button)
  • 4: Auxiliary button (usually the mouse wheel button or middle button)
  • 8: 4th button (typically the “Browser Back” button)
  • 16 : 5th button (typically the “Browser Forward” button)
§client_x: i32
👎Deprecated since 0.3.0: use client_coordinates() instead

The horizontal coordinate within the application’s viewport at which the event occurred (as opposed to the coordinate within the page).

For example, clicking on the left edge of the viewport will always result in a mouse event with a clientX value of 0, regardless of whether the page is scrolled horizontally.

§client_y: i32
👎Deprecated since 0.3.0: use client_coordinates() instead

The vertical coordinate within the application’s viewport at which the event occurred (as opposed to the coordinate within the page).

For example, clicking on the top edge of the viewport will always result in a mouse event with a clientY value of 0, regardless of whether the page is scrolled vertically.

§ctrl_key: bool
👎Deprecated since 0.3.0: use modifiers() instead

True if the control key was down when the mouse event was fired.

§meta_key: bool
👎Deprecated since 0.3.0: use modifiers() instead

True if the meta key was down when the mouse event was fired.

§offset_x: i32
👎Deprecated since 0.3.0: use element_coordinates() instead

The offset in the X coordinate of the mouse pointer between that event and the padding edge of the target node.

§offset_y: i32
👎Deprecated since 0.3.0: use element_coordinates() instead

The offset in the Y coordinate of the mouse pointer between that event and the padding edge of the target node.

§page_x: i32
👎Deprecated since 0.3.0: use page_coordinates() instead

The X (horizontal) coordinate (in pixels) of the mouse, relative to the left edge of the entire document. This includes any portion of the document not currently visible.

Being based on the edge of the document as it is, this property takes into account any horizontal scrolling of the page. For example, if the page is scrolled such that 200 pixels of the left side of the document are scrolled out of view, and the mouse is clicked 100 pixels inward from the left edge of the view, the value returned by pageX will be 300.

§page_y: i32
👎Deprecated since 0.3.0: use page_coordinates() instead

The Y (vertical) coordinate in pixels of the event relative to the whole document.

See page_x.

§screen_x: i32
👎Deprecated since 0.3.0: use screen_coordinates() instead

The X coordinate of the mouse pointer in global (screen) coordinates.

§screen_y: i32
👎Deprecated since 0.3.0: use screen_coordinates() instead

The Y coordinate of the mouse pointer in global (screen) coordinates.

§shift_key: bool
👎Deprecated since 0.3.0: use modifiers() instead

True if the shift key was down when the mouse event was fired.

Implementations§

source§

impl MouseData

source

pub fn new( coordinates: Coordinates, trigger_button: Option<MouseButton>, held_buttons: MouseButtonSet, modifiers: Modifiers ) -> Self

Construct MouseData with the specified properties

Note: the current implementation truncates coordinates. In the future, when we change the internal representation, it may also support a fractional part.

source

pub fn client_coordinates(&self) -> ClientPoint

The event’s coordinates relative to the application’s viewport (as opposed to the coordinate within the page).

For example, clicking in the top left corner of the viewport will always result in a mouse event with client coordinates (0., 0.), regardless of whether the page is scrolled horizontally.

source

pub fn element_coordinates(&self) -> ElementPoint

The event’s coordinates relative to the padding edge of the target element

For example, clicking in the top left corner of an element will result in element coordinates (0., 0.)

source

pub fn page_coordinates(&self) -> PagePoint

The event’s coordinates relative to the entire document. This includes any portion of the document not currently visible.

For example, if the page is scrolled 200 pixels to the right and 300 pixels down, clicking in the top left corner of the viewport would result in page coordinates (200., 300.)

source

pub fn screen_coordinates(&self) -> ScreenPoint

The event’s coordinates relative to the entire screen. This takes into account the window’s offset.

source

pub fn coordinates(&self) -> Coordinates

source

pub fn modifiers(&self) -> Modifiers

The set of modifier keys which were pressed when the event occurred

source

pub fn held_buttons(&self) -> MouseButtonSet

The set of mouse buttons which were held when the event occurred.

source

pub fn trigger_button(&self) -> Option<MouseButton>

The mouse button that triggered the event

This is only guaranteed to indicate which button was pressed during events caused by pressing or releasing a button. As such, it is not reliable for events such as mouseenter, mouseleave, mouseover, mouseout, or mousemove. For example, a value of MouseButton::Primary may also indicate that no button was pressed.

Trait Implementations§

source§

impl Clone for MouseData

source§

fn clone(&self) -> MouseData

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for MouseData

source§

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

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

impl Default for MouseData

source§

fn default() -> MouseData

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

impl<'de> Deserialize<'de> for MouseData

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<&Event> for MouseData

source§

fn from(e: &Event) -> Self

Converts to this type from the input type.
source§

impl From<&MouseEvent> for MouseData

source§

fn from(e: &MouseEvent) -> Self

Converts to this type from the input type.
source§

impl From<Event> for MouseData

source§

fn from(e: Event) -> Self

Converts to this type from the input type.
source§

impl PartialEq<MouseData> for MouseData

source§

fn eq(&self, other: &MouseData) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for MouseData

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for MouseData

source§

impl StructuralEq for MouseData

source§

impl StructuralPartialEq for MouseData

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,