Mouse

:= []

Mouse module - helpers for working with Host.mouse button state.

The host stores one packed state byte per raylib mouse button code 0-6: bit 0 is held, bit 1 is pressed this frame, and bit 2 is released this frame. Pass host.mouse directly to these helpers.

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 sampled for this frame.

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

Check if a mouse button is currently held down.

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

Check if a mouse button is currently up.

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

Check if a mouse button was first pressed this frame.

State

:= {
    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 sampled once at the start of the current frame.

button_up : State, MouseButton -> Bool

Whether a button is currently up.

button_pressed : State, MouseButton -> Bool

Whether a button was first pressed this frame.

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

Current cursor position in logical drawing coordinates.

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

Cursor movement since the previous frame.

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

Horizontal and vertical wheel movement for this frame.

Cursor

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

Native operating-system cursor shapes.

MouseButton

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

Standard mouse buttons sampled by the platform.