#[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
Moved
Cursor moved to pos.
Fields
Button
Button pressed or released at pos.
Fields
Button whose state changed.
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
Wheel
Scroll wheel at pos.
Implementations§
Source§impl PointerEvent
impl PointerEvent
Sourcepub const fn moved(pos: Point, modifiers: Modifiers) -> Self
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));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)));Sourcepub const fn cancelled(pos: Point, modifiers: Modifiers) -> Self
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());Sourcepub const fn wheel(
pos: Point,
delta: WheelDelta,
modifiers: Modifiers,
precise: bool,
) -> Self
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());Sourcepub const fn position(&self) -> Point
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));Sourcepub const fn modifiers(&self) -> Modifiers
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);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)));Sourcepub const fn wheel_delta(&self) -> Option<(WheelDelta, bool)>
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)));Sourcepub const fn is_cancelled(&self) -> bool
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
impl Clone for PointerEvent
Source§fn clone(&self) -> PointerEvent
fn clone(&self) -> PointerEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more