Skip to content

mouse

mouse

Mouse polling. The mousemove, mousepressed, mousereleased and mousewheel callbacks (see events) cover edges; these read the live state.

toMouseButton

proc toMouseButton(b: uint8): MouseButton

The nim2d MouseButton for an SDL button number.

Parameters

  • b (uint8)

Returns

MouseButton

mousePosition

proc mousePosition(): Vec2

Cursor position relative to the window.

Returns

Vec2

mouseX

proc mouseX(): float

The cursor's x position relative to the window.

Returns

float

mouseY

proc mouseY(): float

The cursor's y position relative to the window.

Returns

float

isMouseDown

proc isMouseDown(button: int = 1): bool

Whether a mouse button is held. 1 is left, 2 is middle, 3 is right.

Parameters

  • button (int)

Returns

bool

isMouseDown

proc isMouseDown(button: MouseButton): bool

Whether a mouse button is held, as a MouseButton (the friendly form).

Parameters

  • button (MouseButton)

Returns

bool

setMouseVisible

proc setMouseVisible(visible: bool)

Show or hide the mouse cursor.

Parameters

  • visible (bool)

isMouseVisible

proc isMouseVisible(): bool

Whether the cursor is shown.

Returns

bool

setRelativeMode

proc setRelativeMode(nim2d: Nim2d; enabled: bool)

Capture the mouse and report relative motion, with the cursor hidden. The

mousemove callback then reports movement deltas (dx, dy) without the pointer being pinned at a screen edge, which suits mouse-look and games that steer by mouse movement.

Parameters

  • nim2d (Nim2d)
  • enabled (bool)

isRelativeMode

proc isRelativeMode(nim2d: Nim2d): bool

Whether relative mouse mode is on.

Parameters

  • nim2d (Nim2d)

Returns

bool

setMouseGrabbed

proc setMouseGrabbed(nim2d: Nim2d; grabbed: bool)

Confine the cursor to the window.

Parameters

  • nim2d (Nim2d)
  • grabbed (bool)

isMouseGrabbed

proc isMouseGrabbed(nim2d: Nim2d): bool

Whether the cursor is confined to the window.

Parameters

  • nim2d (Nim2d)

Returns

bool

setMousePosition

proc setMousePosition(nim2d: Nim2d; x, y: float)

Warp the cursor to a position inside the window.

Parameters

  • nim2d (Nim2d)
  • x (float)
  • y (float)
Generated with mkdocstrings-nim