Edit on GitHub


We can override the cursor image with our own provided image. We can do that by creating a new Cursor object and passing in a Pixmap as well as the cursors hot spot coordinates.

Using own image

val cursorImage = resourcesVfs["cursor.png"].readPixmap()

// sets the hot spot to the middle of the cursor
val cursor = Cursor(cursorImage, (cursorImage.width * 0.5f).roundToInt(), (cursorImage.height * 0.5f).roundToInt())

onDispose {
    cursor.dispose() // we need to dispose if we are done with it

System cursor

We can also override the cursor with a system defined cursor by passing in a SystemCursor instead. // nothing to dispose here