Blitz3D+ Command Reference

CanvasMouseX ( canvas )

Parameters

canvas - canvas gadget to measure against

Description

Returns the mouse position across a canvas, in physical canvas pixels.

Requires Extended language mode.

Gives the current pointer x position measured from the canvas's left edge, in the canvas's own render-target pixels - the same units as CanvasPixelWidth and your drawing. That makes it the right coordinate for editor picking: pass it straight to CameraPick on a 3D canvas, or use it to paint under the cursor on a 2D canvas, and it lines up 1:1 with the pixels even under DPI scaling.

Note the difference from event coordinates: mouse events ($201-$206) on the shared queue report logical 96-DPI positions, while CanvasMouseX polls the physical pixel position right now. When the pointer is outside the canvas the value simply goes negative or beyond the canvas width.

The world editor shell sample shows the canvas viewport this is designed for.

See also: CanvasMouseY, CanvasPixelWidth, CreateCanvas, EventX, CameraPick.

Index