Pointer input
Event payloads and pointer controls used by the node input handlers.
ts
import { PointerEvent, DragEvent, WheelEvent, PinchContext, KeyModifiers, Pointer } from "willow";PointerEvent
ts
class PointerEventPayload handed to a node's pointer callbacks (onPointerDown, onPointerUp, onClick). x/y are in the node's local space; worldX/worldY are scene-world coordinates; button is the mouse button index (0 = left, 1 = right, 2 = middle); modifiers is a KeyModifiers bitmask of the keyboard modifier keys held during the event (e.g. (e.modifiers & KeyModifiers.SHIFT) !== 0); target is the Node the pointer hit.
PointerEvent: properties
| Member | Description |
|---|---|
x: float | Pointer X in the hit node's local space. |
y: float | Pointer Y in the hit node's local space. |
worldX: float | Pointer X in scene-world coordinates. |
worldY: float | Pointer Y in scene-world coordinates. |
screenX: float | Pointer X in logical screen pixels, before the camera. |
screenY: float | Pointer Y in logical screen pixels, before the camera. |
button: int | Mouse button index: 0 = left, 1 = right, 2 = middle. |
modifiers: int | KeyModifiers bitmask of the keyboard modifier keys held during the event. |
target: Node | The Node the pointer hit. |
DragEvent
ts
class DragEventPointer drag payload. Coordinates and deltas mirror willow::DragContext. modifiers is a KeyModifiers bitmask of the keyboard modifier keys held during the drag.
DragEvent: properties
| Member | Description |
|---|---|
x: float | Pointer X in the target node's local space. |
y: float | Pointer Y in the target node's local space. |
worldX: float | Pointer X in scene-world coordinates. |
worldY: float | Pointer Y in scene-world coordinates. |
startX: float | World-space X where this drag began. |
startY: float | World-space Y where this drag began. |
deltaX: float | World-space X delta since the drag began. |
deltaY: float | World-space Y delta since the drag began. |
screenDeltaX: float | Screen-space X delta since the drag began. |
screenDeltaY: float | Screen-space Y delta since the drag began. |
pointerId: int | Platform pointer/touch id, for disambiguating multiple simultaneous drags. |
modifiers: int | KeyModifiers bitmask of the keyboard modifier keys held during the drag. |
target: Node | The Node this drag started on. |
WheelEvent
ts
class WheelEventMouse wheel / trackpad scroll payload, handed to Node.onWheel.
WheelEvent: properties
| Member | Description |
|---|---|
x: float | Pointer X in the target node's local space. |
y: float | Pointer Y in the target node's local space. |
worldX: float | Pointer X in scene-world coordinates (after the camera). |
worldY: float | Pointer Y in scene-world coordinates (after the camera). |
screenX: float | Pointer X in logical screen pixels, before the camera. |
screenY: float | Pointer Y in logical screen pixels, before the camera. |
deltaX: float | Horizontal scroll for the frame. |
deltaY: float | Vertical scroll for the frame. |
modifiers: int | KeyModifiers bitmask of the keyboard modifier keys held during the scroll. |
target: Node | The Node whose onWheel handled this event. |
PinchContext
ts
class PinchContextTwo-finger pinch/rotate gesture payload, handed to Node.onPinch. centerX/centerY are the midpoint between the two touch points in world coordinates. scale/rotation are CUMULATIVE since the gesture began, not a per-frame delta: scale is 1.0 and rotation is 0 at gesture start, and both track the pinch's total change since then. No target field, a pinch has no single hit node the way click/drag do.
PinchContext: properties
| Member | Description |
|---|---|
centerX: float | Midpoint X between the two touch points, in world coordinates. |
centerY: float | Midpoint Y between the two touch points, in world coordinates. |
scale: float | Cumulative scale factor since the gesture began. 1.0 at gesture start. |
rotation: float | Cumulative rotation in radians since the gesture began. 0 at gesture start. |
KeyModifiers
ts
class KeyModifiersKeyboard modifier-key bitmask constants. Carried on PointerEvent.modifiers / DragEvent.modifiers.
KeyModifiers: static properties
| Member | Description |
|---|---|
static readonly SHIFT: int | Shift key bit. |
static readonly CTRL: int | Ctrl key bit. |
static readonly ALT: int | Alt key bit. |
static readonly META: int | Meta/Cmd/Windows key bit. |
Pointer
ts
class PointerModule-level pointer capture and drag-threshold controls.
Pointer: static methods
| Member | Description |
|---|---|
static capture(node: Node, pointerId?: int): void | Routes every subsequent pointer event for pointerId (default: the primary pointer) to node regardless of hit-testing, until release is called. Used to keep a drag on its originating node even after the pointer leaves its bounds. |
static release(pointerId?: int): void | Releases a capture previously set by capture, restoring normal hit-testing. |
static setDragDeadZone(px: float): void | Sets the minimum pointer movement, in pixels, before a press is treated as a drag rather than a click. |
static dragDeadZone(): float | The current drag dead-zone in pixels. See setDragDeadZone. |