gdk.cursor
Module for [Cursor] class
Types 3
[gdk.cursor.Cursor] 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 [gdk.surface.Surface.setCursor] or [gdk.surface.Surface.setDeviceCursor]. Applications will typically use higher-level GTK functions such as [[gtk.widget.Widget.setCursor]](../gtk4/method.Widget.set_cursor.html) instead.
Cursors are not bound to a given [gdk.display.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 [gdk.cursor.Cursor.newFromName]. 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 [gdk.cursor.Cursor.newFromTexture] and provide an image to use for the cursor.
To ease work with unsupported cursors, a fallback cursor can be provided. If a [gdk.surface.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.
CursorGidBuilder builder()Get builder for [gdk.cursor.Cursor] Returns: New builder objectgdk.cursor.Cursor fallback() @propertyGet `fallback` property. Returns: Cursor to fall back to if this cursor cannot be displayed.int hotspotX() @propertyGet `hotspotX` property. Returns: X position of the cursor hotspot in the cursor image.int hotspotY() @propertyGet `hotspotY` property. Returns: Y position of the cursor hotspot in the cursor image.gdk.texture.Texture texture() @propertyGet `texture` property. Returns: The texture displayed by this cursor.gdk.cursor.Cursor newFromName(string name, gdk.cursor.Cursor fallback = null)Creates a new cursor by looking up name in the current cursor theme.gdk.cursor.Cursor newFromTexture(gdk.texture.Texture texture, int hotspotX, int hotspotY, gdk.cursor.Cursor fallback = null)Creates a new cursor from a [gdk.texture.Texture].gdk.cursor.Cursor getFallback()Returns the fallback for this cursor.int getHotspotX()Returns the horizontal offset of the hotspot.int getHotspotY()Returns the vertical offset of the hotspot.string getName()Returns the name of the cursor.gdk.texture.Texture getTexture()Returns the texture for the cursor.T fallback(gdk.cursor.Cursor propval)Set `fallback` property. Params: propval = Cursor to fall back to if this cursor cannot be displayed. Returns: Builder instance for fluent chainingT hotspotX(int propval)Set `hotspotX` property. Params: propval = X position of the cursor hotspot in the cursor image. Returns: Builder instance for fluent chainingT hotspotY(int propval)Set `hotspotY` property. Params: propval = Y position of the cursor hotspot in the cursor image. Returns: Builder instance for fluent chainingT name(string propval)Set `name` property. Params: propval = Name of this this cursor.T texture(gdk.texture.Texture propval)Set `texture` property. Params: propval = The texture displayed by this cursor.