ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Cursor

Catalogue

Cursor

A cursor drawn by the game: built-in shapes, custom images and one cursor for dxDraw, GUI and browsers.

The game's cursor, not the system's

showCursor shows a cursor drawn inside the game, in the same frame as the rest of the picture. The Windows cursor is hidden meanwhile, so there are no two arrows, no flicker and no lag behind the interface. One cursor serves dxDraw drawing, GUI windows and CEF browsers: over a text field it turns into a text beam on its own, over a window edge into resize arrows, over a browser link into a hand.

bindKey("m", "down", function()
    showCursor(not isCursorShowing())
end)
Cursor over the game
Cursor over the gameThe arrow after showCursor(true).

Shapes

The shape changes by itself over GUI and browsers. setCursorType pins it, and setCursorType() with no argument hands control back.

Built-in shapes
Built-in shapesFrom the left: arrow, hand, text, crosshair, wait, help, move, sizewe, sizens, sizenesw, sizenwse, no.
NameWhen
arrowdefault arrow
handsomething clickable
texttext field
crosshairpicking a point
wait, progresssomething is loading (spinning ring)
helpa hint
movemoving
sizewe, sizens, sizenesw, sizenwsehorizontal, vertical and diagonal resizing
noaction not available
nonecursor hidden but still working (e.g. your own crosshair drawn with dxDraw)

Custom image

setCursorImage swaps the cursor for any image: a PNG file from the resource or a texture from dxCreateTexture or dxCreateRenderTarget. hotX and hotY are the click point inside the image, counted from its top-left corner.

-- 32x32 crosshair, clicks with its centre
setCursorImage("img/crosshair.png", 16, 16)

-- back to the built-in cursor
setCursorImage(false)

Pixels are copied at the moment of the call. If you draw the cursor into a render target and want to animate it, call setCursorImage again after every change.

Transparency and clean-up

setCursorAlpha sets the cursor's transparency (0 to 255). Shape, image and transparency are shared by all resources: when the resource that changed them stops, the cursor returns to the plain arrow, so one resource never leaves the others with a hidden cursor.