Mouse

Mouse helpers for input.devices.mouse.

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

The types and pure helpers live in the companion roc-ray-types package so reusable packages can depend on them without depending on this platform. This module re-exports them, so Snapshot here and in the package are the same nominal type and its receivers are available either way.

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.

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!.

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 retained for this input interval.

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 during this input interval.

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

Check if a mouse button was released during this input interval.

Snapshot : Snapshot

Mouse input sampled once at the start of the current frame.

Declared in the roc-ray-types package's Mouse and re-exported here, which is also where its receivers are documented.

Cursor : Cursor

Native operating-system cursor shapes.

Button : Button

Standard mouse buttons sampled by the platform.

Source : Source

Where pointer input comes from: Hardware, or a Virtual pointer whose position and buttons the app states itself.

A virtual source is how a run drives its own pointer -- a scripted demo, a recorded walkthrough, a headless test that has to click something. The host reports it through input.devices.mouse exactly as it reports the hardware one, so nothing downstream can tell the difference.

CursorMode : [Visible, Hidden, Locked]

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