Cursor

open class Cursor(pointer: <Error class: unknown class><<Error class: unknown class>>)

GdkCursor is used to create and destroy cursors.

Cursors are immutable objects, so once you created them, there is no way to modify them later. You should create a new cursor when you want to change something about it.

Cursors by themselves are not very interesting: they must be bound to a window for users to see them. This is done with method@Gdk.Surface.set_cursor or method@Gdk.Surface.set_device_cursor. Applications will typically use higher-level GTK functions such as ../gtk4/method.Widget.set_cursor.html instead.

Cursors are not bound to a given class@Gdk.Display, so they can be shared. However, the appearance of cursors may vary when used on different platforms.

Named and texture cursors

There are multiple ways to create cursors. The platform's own cursors can be created with ctor@Gdk.Cursor.new_from_name. That function lists the commonly available names that are shared with the CSS specification. Other names may be available, depending on the platform in use. On some platforms, what images are used for named cursors may be influenced by the cursor theme.

Another option to create a cursor is to use ctor@Gdk.Cursor.new_from_texture and provide an image to use for the cursor.

To ease work with unsupported cursors, a fallback cursor can be provided. If a class@Gdk.Surface cannot use a cursor because of the reasons mentioned above, it will try the fallback cursor. Fallback cursors can themselves have fallback cursors again, so it is possible to provide a chain of progressively easier to support cursors. If none of the provided cursors can be supported, the default cursor will be the ultimate fallback.

Constructors

Link copied to clipboard
constructor(callback: CursorGetTextureCallback, fallback: Cursor? = null)

Creates a new callback-based cursor object.

constructor(name: String, fallback: Cursor? = null)

Creates a new cursor by looking up @name in the current cursor theme.

constructor(texture: Texture, hotspotX: <Error class: unknown class>, hotspotY: <Error class: unknown class>, fallback: Cursor? = null)

Creates a new cursor from a GdkTexture.

constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open val fallback: Cursor?

Cursor to fall back to if this cursor cannot be displayed.

Link copied to clipboard
val gdkCursorPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open val hotspotX: <Error class: unknown class>

X position of the cursor hotspot in the cursor image.

Link copied to clipboard
open val hotspotY: <Error class: unknown class>

Y position of the cursor hotspot in the cursor image.

Link copied to clipboard
open val name: String?

Name of this this cursor.

Link copied to clipboard
open val texture: Texture?

The texture displayed by this cursor.