Skip to main content

Pointer

Struct Pointer 

Source
pub struct Pointer {
    pub x: f32,
    pub y: f32,
    pub button: PointerButton,
    pub kind: PointerKind,
    pub id: PointerId,
    pub pressure: Option<f32>,
}
Expand description

One pointer sample, in logical pixels. The argument shape for [crate::runtime::RunnerCore::pointer_moved], [crate::runtime::RunnerCore::pointer_down], and [crate::runtime::RunnerCore::pointer_up].

Modeled on the DOM PointerEvent interface so backends that already speak browser pointer events can map fields directly. button is meaningful on pointer_down / pointer_up and is ignored on pointer_moved; constructors default it to PointerButton::Primary for that case.

Fields§

§x: f32

X coordinate in logical pixels relative to the window origin.

§y: f32

Y coordinate in logical pixels relative to the window origin.

§button: PointerButton

Which button this event refers to. Ignored by pointer_moved.

§kind: PointerKind

Physical kind of pointer (mouse / touch / pen).

§id: PointerId

Stable per-pointer ID. Use PointerId::PRIMARY for single-pointer backends.

§pressure: Option<f32>

Normalized pressure in 0.0..=1.0 when the device reports it (pen, force-touch). None when unavailable; mouse backends always pass None.

Implementations§

Source§

impl Pointer

Source

pub fn mouse(x: f32, y: f32, button: PointerButton) -> Self

A mouse-driven pointer at (x, y) for the given button. Use from mouse-only hosts and synthetic tests.

Source

pub fn moving(x: f32, y: f32) -> Self

A mouse pointer for pointer_moved, where button is irrelevant. Equivalent to Pointer::mouse(x, y, PointerButton::Primary).

Source

pub fn touch(x: f32, y: f32, button: PointerButton, id: PointerId) -> Self

A touch contact at (x, y) carrying the given pointer ID. Backends translating browser PointerEvent should pass the browser’s pointerId directly.

Trait Implementations§

Source§

impl Clone for Pointer

Source§

fn clone(&self) -> Pointer

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Pointer

Source§

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

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

impl PartialEq for Pointer

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Pointer

Source§

impl StructuralPartialEq for Pointer

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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> Scalar for T
where T: 'static + Clone + PartialEq + Debug,