Skip to content

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 PointerEvent

Payload 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 ​

MemberDescription
x: floatPointer X in the hit node's local space.
y: floatPointer Y in the hit node's local space.
worldX: floatPointer X in scene-world coordinates.
worldY: floatPointer Y in scene-world coordinates.
screenX: floatPointer X in logical screen pixels, before the camera.
screenY: floatPointer Y in logical screen pixels, before the camera.
button: intMouse button index: 0 = left, 1 = right, 2 = middle.
modifiers: intKeyModifiers bitmask of the keyboard modifier keys held during the event.
target: NodeThe Node the pointer hit.

DragEvent ​

ts
class DragEvent

Pointer drag payload. Coordinates and deltas mirror willow::DragContext. modifiers is a KeyModifiers bitmask of the keyboard modifier keys held during the drag.

DragEvent: properties ​

MemberDescription
x: floatPointer X in the target node's local space.
y: floatPointer Y in the target node's local space.
worldX: floatPointer X in scene-world coordinates.
worldY: floatPointer Y in scene-world coordinates.
startX: floatWorld-space X where this drag began.
startY: floatWorld-space Y where this drag began.
deltaX: floatWorld-space X delta since the drag began.
deltaY: floatWorld-space Y delta since the drag began.
screenDeltaX: floatScreen-space X delta since the drag began.
screenDeltaY: floatScreen-space Y delta since the drag began.
pointerId: intPlatform pointer/touch id, for disambiguating multiple simultaneous drags.
modifiers: intKeyModifiers bitmask of the keyboard modifier keys held during the drag.
target: NodeThe Node this drag started on.

WheelEvent ​

ts
class WheelEvent

Mouse wheel / trackpad scroll payload, handed to Node.onWheel.

WheelEvent: properties ​

MemberDescription
x: floatPointer X in the target node's local space.
y: floatPointer Y in the target node's local space.
worldX: floatPointer X in scene-world coordinates (after the camera).
worldY: floatPointer Y in scene-world coordinates (after the camera).
screenX: floatPointer X in logical screen pixels, before the camera.
screenY: floatPointer Y in logical screen pixels, before the camera.
deltaX: floatHorizontal scroll for the frame.
deltaY: floatVertical scroll for the frame.
modifiers: intKeyModifiers bitmask of the keyboard modifier keys held during the scroll.
target: NodeThe Node whose onWheel handled this event.

PinchContext ​

ts
class PinchContext

Two-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 ​

MemberDescription
centerX: floatMidpoint X between the two touch points, in world coordinates.
centerY: floatMidpoint Y between the two touch points, in world coordinates.
scale: floatCumulative scale factor since the gesture began. 1.0 at gesture start.
rotation: floatCumulative rotation in radians since the gesture began. 0 at gesture start.

KeyModifiers ​

ts
class KeyModifiers

Keyboard modifier-key bitmask constants. Carried on PointerEvent.modifiers / DragEvent.modifiers.

KeyModifiers: static properties ​

MemberDescription
static readonly SHIFT: intShift key bit.
static readonly CTRL: intCtrl key bit.
static readonly ALT: intAlt key bit.
static readonly META: intMeta/Cmd/Windows key bit.

Pointer ​

ts
class Pointer

Module-level pointer capture and drag-threshold controls.

Pointer: static methods ​

MemberDescription
static capture(node: Node, pointerId?: int): voidRoutes 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): voidReleases a capture previously set by capture, restoring normal hit-testing.
static setDragDeadZone(px: float): voidSets the minimum pointer movement, in pixels, before a press is treated as a drag rather than a click.
static dragDeadZone(): floatThe current drag dead-zone in pixels. See setDragDeadZone.