Mouse

Mouse helpers for input.devices.mouse.

Pass input.devices.mouse directly to these helpers; there is nothing to construct, and the methods read the same either way: input.devices.mouse.position().

position : { ..state, x : F32, y : F32 } -> { x : F32, y : F32 }

Current cursor position in logical drawing coordinates.

delta : { ..state, delta_x : F32, delta_y : F32 } -> { x : F32, y : F32 }

Cursor movement since the previous frame, sampled once by the host.

wheel_delta : { ..state, wheel_x : F32, wheel_y : F32 } -> { x : F32, y : F32 }

Horizontal and vertical wheel movement since the previous input, every notch in the interval summed.

virtual_at : { x : F32, y : F32 } -> Source

A virtual pointer at a position, with no button held.

virtual_click_at : { x : F32, y : F32 } -> Source

A virtual pointer at a position with the left button held, so the next input reports a press there.

button_down : { ..state, buttons : List(U8) }, Button -> Bool

Check if a mouse button is currently held down.

button_up : { ..state, buttons : List(U8) }, Button -> Bool

Check if a mouse button is currently up.

button_pressed : { ..state, buttons : List(U8) }, Button -> Bool

Check if a mouse button was pressed at least once since the previous input. A click that began and ended between two cycles still counts. Coalesced per button; the ordered record with every click and its position is Devices.Snapshot.events.

button_released : { ..state, buttons : List(U8) }, Button -> Bool

Check if a mouse button was released at least once since the previous input.

set_source! : Source => {}

Hand pointer input to a scripted source, or back to the hardware mouse.

Legal in init!, update!, and tasks; refused in render!.

set_cursor! : Cursor => {}

Set the native cursor shape.

Legal in init!, update!, and tasks; refused in render!.

set_cursor_mode! : CursorMode => {}

Set cursor visibility and capture, applied atomically as one operation.

Legal in init!, update!, and tasks; refused in render!.

Snapshot

:= {
    buttons : List(U8),
    left : Bool,
    middle : Bool,
    right : Bool,
    wheel : F32,
    wheel_x : F32,
    wheel_y : F32,
    delta_x : F32,
    delta_y : F32,
    x : F32,
    y : F32,
}

Mouse input for one cycle. Position, movement and the held bits are samples at the cycle boundary; the pressed and released bits and the wheel are events recorded since the previous input.

button_up : Snapshot, Button -> Bool

Whether a button is currently up.

button_pressed : Snapshot, Button -> Bool

Whether a button was pressed at least once since the previous input. A click that began and ended between two cycles still counts.

button_released : Snapshot, Button -> Bool

Whether a button was released at least once since the previous input.

position : Snapshot -> { x : F32, y : F32 }

Current cursor position in logical drawing coordinates.

delta : Snapshot -> { x : F32, y : F32 }

Cursor movement since the previous frame.

wheel_delta : Snapshot -> { x : F32, y : F32 }

Horizontal and vertical wheel movement since the previous input, every notch in the interval summed.

Cursor

:= [
    Default,
    Arrow,
    IBeam,
    Crosshair,
    PointingHand,
    ResizeEastWest,
    ResizeNorthSouth,
    ResizeNorthwestSoutheast,
    ResizeNortheastSouthwest,
    ResizeAll,
    NotAllowed,
]

Native operating-system cursor shapes.

is_eq : _

Compare two of these values.

Button

:= [Left, Right, Middle, Side, Extra, Forward, Back]

Standard mouse buttons sampled by the platform.

is_eq : _

Compare two of these values, so a Devices.Event can be compared and a click can be matched against a remembered button.

Source

:= [Hardware, Virtual({ x : F32, y : F32, left : Bool, middle : Bool, right : Bool, wheel : F32 })]

Select hardware pointer samples or deterministic application-provided samples. Where pointer input comes from: Hardware, or a Virtual pointer whose position and buttons the app states itself. Mouse.set_source! on the platform is what switches between them.

CursorMode : [Visible, Hidden, Locked]

Cursor visibility and capture policy, applied atomically as one tagged operation by Mouse.set_cursor_mode!.