Skip to main content

PointerId

Struct PointerId 

Source
pub struct PointerId {
    pub source: PointerSource,
    pub slot: u32,
}
Expand description

The identity of one pointer contact: which device it comes from and which slot on that device.

It rides beside a PointerEvent, never inside it: a shell hands a touch contact to the root as InputEvent::PointerContact, the root unwraps it, and the widget receiving the plain InputEvent::Pointer reads the identity from EventCtx::pointer_id. A bare InputEvent::Pointer from a shell means PointerId::MOUSE.

A slot is the shell’s own numbering of simultaneous contacts on one source: slot 0 is the gesture’s first contact, and a slot is free again once its contact ended. The mouse only ever has slot 0.

§Multi-contact contract

Applied at the root (crate::app::RenderRoot::event):

  • (a) With no live pointer capture, a slot-0 contact is hit-tested exactly like a plain InputEvent::Pointer — the same overlay, hover, focus and blur bookkeeping — and a capture taken on its Down latches this id as the gesture’s claimant.
  • (b) With no live capture, a contact on slot 1 or above is dropped at the root. Additional contacts exist only inside a captured gesture.
  • (c) While a capture is live, the claimant’s own events take the captured path as usual. An event with any other id reaches the captor — and only the captor: the containers above it on that path forward it without running their own handling — only if the captor opted in with EventCtx::capture_contacts on its capturing Down; otherwise the root drops it. Only the claimant’s Up/Cancel ends the capture: another contact’s Up/Cancel never releases it, whether it came from a touch while a mouse holds the capture or the other way round. A container that takes the gesture over from the captor (EventCtx::release_captured_child) ends the opt-in, and the other contacts are dropped from then on.

See InputEvent::PointerContact for the full contract.

Fields§

§source: PointerSource

The device the contact comes from.

§slot: u32

The contact’s slot on that device (0 for the first contact).

Implementations§

Source§

impl PointerId

Source

pub const MOUSE: PointerId

The mouse pointer: the identity a bare InputEvent::Pointer carries, and what EventCtx::pointer_id reports when nothing else is known.

Source

pub const fn touch(slot: u32) -> PointerId

The touch contact in slot (0 for the gesture’s first finger).

Trait Implementations§

Source§

impl Clone for PointerId

Source§

fn clone(&self) -> Self

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 Copy for PointerId

Source§

impl Debug for PointerId

Source§

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

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

impl Eq for PointerId

Source§

impl Hash for PointerId

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for PointerId

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PointerId

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.