Scoop API

scoop:scoop.window:0.1.0

src/input/pointer.scoop

Selected production source · src/input/pointer.scoop

1package scoop.window
3/** Position and modifiers captured from one native positional input event. */
4public struct PointerState(
5 val logicalPosition: LogicalPosition,
6 val physicalPosition: PhysicalPosition,
7 val scaleFactor: Double,
8 val modifiers: Modifiers,
9 val time: InputTime,
10 val deviceId: DeviceId? = None
13/** Native button numbering is retained for additional mouse buttons. */
14public enum MouseButton {
15 Left, Right, Middle, Other(UInt)
18/** Line deltas are never converted with an invented line height. */
19public enum ScrollDelta {
20 LineDelta(Double, Double), PixelDelta(Double, Double)
23/** A native phase; None is normal for traditional wheel events. */
24public enum ScrollPhase {
25 None, MayBegin, Began, Stationary, Changed, Ended, Cancelled
28/** Ends native positional input without synthesizing a successful release. */
29public enum PointerCancelReason {
30 FocusLost, CaptureLost, SystemOperation, Modal
33/**
34 * Window-relative pointer events, with independent wheel and momentum phases.
35 * Button carries a consecutive click count of at least one. The matching release
36 * retains its press count; cancellation ends the sequence without a release.
37 */
38public enum PointerEvent {
39 Entered(PointerState), Left(PointerState), Moved(PointerState),
40 Button(PointerState, MouseButton, ElementState, Int),
41 Wheel(PointerState, ScrollDelta, ScrollPhase, ScrollPhase),
42 Cancelled(PointerCancelReason, InputTime)
45internal fun copyPointerCancelReason(reason: Int): PointerCancelReason =
46 when (reason) {
47 0 -> PointerCancelReason.FocusLost
48 1 -> PointerCancelReason.CaptureLost
49 2 -> PointerCancelReason.SystemOperation
50 3 -> PointerCancelReason.Modal
51 else -> throw WindowException("unknown pointer cancellation", WindowErrorKind.NativeFailure)
52 }