Enum PointerEvent

Source
#[non_exhaustive]
pub enum PointerEvent { Moved { pos: Point, modifiers: Modifiers, }, Button { pos: Point, button: PointerButton, pressed: bool, modifiers: Modifiers, }, Cancelled { pos: Point, modifiers: Modifiers, }, Wheel { pos: Point, delta: WheelDelta, modifiers: Modifiers, precise: bool, }, }
Expand description

Pointer move, button, cancellation, or wheel event.

§Examples

use ailloli_ui_core::{event::{Modifiers, PointerEvent}, Point};
let event = PointerEvent::moved(Point::new(1.0, 2.0), Modifiers::default());
assert_eq!(event.position(), Point::new(1.0, 2.0));

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Moved

Cursor moved to pos.

Fields

§pos: Point

Current logical window position.

§modifiers: Modifiers

Modifier snapshot at the time of motion.

§

Button

Button pressed or released at pos.

Fields

§pos: Point

Logical window position of the transition.

§button: PointerButton

Button whose state changed.

§pressed: bool

true for press and false for release.

§modifiers: Modifiers

Modifier snapshot at the time of transition.

§

Cancelled

The active gesture was cancelled by the host or input provider.

Cancellation never represents a click release. Runtimes must clear press/capture state for the corresponding PointerId.

Fields

§pos: Point

Last known logical window position.

§modifiers: Modifiers

Modifier snapshot at cancellation time.

§

Wheel

Scroll wheel at pos.

Fields

§pos: Point

Logical window position associated with the wheel input.

§delta: WheelDelta

Provider wheel displacement before widget-specific normalization.

§modifiers: Modifiers

Modifier snapshot at wheel time.

§precise: bool

High-resolution trackpad scroll when supported.

Implementations§

Source§

impl PointerEvent

Source

pub const fn moved(pos: Point, modifiers: Modifiers) -> Self

Creates a pointer movement event in logical coordinates.

§Examples
use ailloli_ui_core::{event::{Modifiers, PointerEvent}, Point};
assert_eq!(PointerEvent::moved(Point::new(1.0, 2.0), Modifiers::default()).position(), Point::new(1.0, 2.0));
Source

pub const fn button( pos: Point, button: PointerButton, pressed: bool, modifiers: Modifiers, ) -> Self

Creates a pointer-button transition in logical coordinates.

§Examples
use ailloli_ui_core::{event::{Modifiers, PointerButton, PointerEvent}, Point};
let event = PointerEvent::button(Point::default(), PointerButton::Left, true, Modifiers::default());
assert_eq!(event.button_transition(), Some((PointerButton::Left, true)));
Source

pub const fn cancelled(pos: Point, modifiers: Modifiers) -> Self

Creates a pointer cancellation event.

§Examples
use ailloli_ui_core::{event::{Modifiers, PointerEvent}, Point};
assert!(PointerEvent::cancelled(Point::default(), Modifiers::default()).is_cancelled());
Source

pub const fn wheel( pos: Point, delta: WheelDelta, modifiers: Modifiers, precise: bool, ) -> Self

Creates a pointer-wheel event in logical coordinates.

§Examples
use ailloli_ui_core::{event::{Modifiers, PointerEvent, WheelDelta}, Point};
let event = PointerEvent::wheel(Point::default(), WheelDelta::LineDelta { x: 0.0, y: 1.0 }, Modifiers::default(), false);
assert!(event.wheel_delta().is_some());
Source

pub const fn position(&self) -> Point

Logical position associated with this event.

§Examples
use ailloli_ui_core::{event::{Modifiers, PointerEvent}, Point};
let event = PointerEvent::moved(Point::new(2.0, 3.0), Modifiers::default());
assert_eq!(event.position(), Point::new(2.0, 3.0));
Source

pub const fn modifiers(&self) -> Modifiers

Keyboard modifiers observed with this event.

§Examples
use ailloli_ui_core::{event::{Modifiers, PointerEvent}, Point};
let modifiers = Modifiers { shift: true, ..Modifiers::default() };
assert!(PointerEvent::moved(Point::default(), modifiers).modifiers().shift);
Source

pub const fn button_transition(&self) -> Option<(PointerButton, bool)>

Returns the button and transition state for a button event.

The boolean is true for press and false for release; all other event variants return None.

§Examples
use ailloli_ui_core::{event::{Modifiers, PointerButton, PointerEvent}, Point};
let event = PointerEvent::button(Point::default(), PointerButton::Right, false, Modifiers::default());
assert_eq!(event.button_transition(), Some((PointerButton::Right, false)));
Source

pub const fn wheel_delta(&self) -> Option<(WheelDelta, bool)>

Returns wheel displacement and the high-resolution flag for a wheel event.

§Examples
use ailloli_ui_core::{event::{Modifiers, PointerEvent, WheelDelta}, Point};
let event = PointerEvent::wheel(Point::default(), WheelDelta::PixelDelta { x: 0.0, y: 2.0 }, Modifiers::default(), true);
assert_eq!(event.wheel_delta(), Some((WheelDelta::PixelDelta { x: 0.0, y: 2.0 }, true)));
Source

pub const fn is_cancelled(&self) -> bool

Returns whether the provider cancelled the active gesture.

§Examples
use ailloli_ui_core::{event::{Modifiers, PointerEvent}, Point};
assert!(!PointerEvent::moved(Point::default(), Modifiers::default()).is_cancelled());

Trait Implementations§

Source§

impl Clone for PointerEvent

Source§

fn clone(&self) -> PointerEvent

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 PointerEvent

Source§

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

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

impl PartialEq for PointerEvent

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 StructuralPartialEq for PointerEvent

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