1.10 <GdkCursor>

Class: <GdkCursor>

It derives from <GObject>.

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 surface:set-cursor or surface:set-device-cursor. Applications will typically use higher-level GTK functions such as gtk_widget_set_cursor() instead.

Cursors are not bound to a given <GdkDisplay>, 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 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 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 <GdkSurface> 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.

Properties

Property: cursor:fallback self

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

Its value is a <GdkCursor>, or #f.

It can only be set when the object is made, with #:fallback.

Property: cursor:hotspot-x self

X position of the cursor hotspot in the cursor image.

Its value is a 32-bit integer.

It can only be set when the object is made, with #:hotspot-x.

Property: cursor:hotspot-y self

Y position of the cursor hotspot in the cursor image.

Its value is a 32-bit integer.

It can only be set when the object is made, with #:hotspot-y.

Property: cursor:name self

Name of this this cursor.

The name will be #f if the cursor was created from a texture.

Its value is a string, or #f.

It can only be set when the object is made, with #:name.

Property: cursor:texture self

The texture displayed by this cursor.

The texture will be #f if the cursor was created from a name.

Its value is a <GdkTexture>, or #f.

It can only be set when the object is made, with #:texture.

Procedures

Method: cursor:get-fallback self ⇒ %return
Method: get-fallback self ⇒ %return

Returns the fallback for this self.

The fallback will be used if this cursor is not available on a given <GdkDisplay>. For named cursors, this can happen when using nonstandard names or when using an incomplete cursor theme. For textured cursors, this can happen when the texture is too large or when the <GdkDisplay> it is used on does not support textured cursors.

self

Passed: a <GdkCursor>.

a <GdkCursor>

%return

Returned: a <GdkCursor>, or #f.

the fallback of the cursor or #f to use the default cursor as fallback

Method: cursor:get-hotspot-x self ⇒ %return
Method: get-hotspot-x self ⇒ %return

Returns the horizontal offset of the hotspot.

The hotspot indicates the pixel that will be directly above the cursor.

Note that named cursors may have a nonzero hotspot, but this function will only return the hotspot position for cursors created with cursor:new-from-texture.

self

Passed: a <GdkCursor>.

a <GdkCursor>

%return

Returned: a 32-bit integer.

the horizontal offset of the hotspot or 0 for named cursors

Method: cursor:get-hotspot-y self ⇒ %return
Method: get-hotspot-y self ⇒ %return

Returns the vertical offset of the hotspot.

The hotspot indicates the pixel that will be directly above the cursor.

Note that named cursors may have a nonzero hotspot, but this function will only return the hotspot position for cursors created with cursor:new-from-texture.

self

Passed: a <GdkCursor>.

a <GdkCursor>

%return

Returned: a 32-bit integer.

the vertical offset of the hotspot or 0 for named cursors

Method: cursor:get-name self ⇒ %return
Method: get-name self ⇒ %return

Returns the name of the cursor.

If the cursor is not a named cursor, #f will be returned.

self

Passed: a <GdkCursor>.

a <GdkCursor>

%return

Returned: a string, or #f.

the name of the cursor or #f if it is not a named cursor

Method: cursor:get-texture self ⇒ %return
Method: get-texture self ⇒ %return

Returns the texture for the cursor.

If the cursor is a named cursor, #f will be returned.

self

Passed: a <GdkCursor>.

a <GdkCursor>

%return

Returned: a <GdkTexture>, or #f.

the texture for cursor or #f if it is a named cursor

Procedure: cursor:new-from-callback callback [fallback] ⇒ %return

Creates a new callback-based cursor object.

Cursors of this kind produce textures for the cursor image on demand, when the callback is called.

callback

Passed: a procedure.

the GdkCursorGetTextureCallback

See GdkCursorGetTextureCallback for how it is called.

fallback

Passed, or left out: a <GdkCursor>, or #f.

the <GdkCursor> to fall back to when this one cannot be supported

%return

Returned: a <GdkCursor>, or #f.

a new <GdkCursor>

data

Not passed: guile-gi supplies it.

data to pass to callback

destroy

Not passed: guile-gi supplies it.

destroy notify for data

See GDestroyNotify for how it is called.

Procedure: cursor:new-from-name name [fallback] ⇒ %return

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

A recommended set of cursor names that will work across different platforms can be found in the CSS specification:

| | | | | — | — | — | | | "none" | No cursor | | ![](default_cursor.png) | "default" | The default cursor | | ![](help_cursor.png) | "help" | Help is available | | ![](pointer_cursor.png) | "pointer" | Indicates a link or interactive element | | ![](context_menu_cursor.png) |"context-menu" | A context menu is available | | ![](progress_cursor.png) | "progress" | Progress indicator | | ![](wait_cursor.png) | "wait" | Busy cursor | | ![](cell_cursor.png) | "cell" | Cell(s) may be selected | | ![](crosshair_cursor.png) | "crosshair" | Simple crosshair | | ![](text_cursor.png) | "text" | Text may be selected | | ![](vertical_text_cursor.png) | "vertical-text" | Vertical text may be selected | | ![](alias_cursor.png) | "alias" | DND: Something will be linked | | ![](copy_cursor.png) | "copy" | DND: Something will be copied | | ![](move_cursor.png) | "move" | DND: Something will be moved | | ![](dnd_ask_cursor.png) | "dnd-ask" | DND: User can choose action to be carried out | | ![](no_drop_cursor.png) | "no-drop" | DND: Can’t drop here | | ![](not_allowed_cursor.png) | "not-allowed" | DND: Action will not be carried out | | ![](grab_cursor.png) | "grab" | DND: Something can be grabbed | | ![](grabbing_cursor.png) | "grabbing" | DND: Something is being grabbed | | ![](n_resize_cursor.png) | "n-resize" | Resizing: Move north border | | ![](e_resize_cursor.png) | "e-resize" | Resizing: Move east border | | ![](s_resize_cursor.png) | "s-resize" | Resizing: Move south border | | ![](w_resize_cursor.png) | "w-resize" | Resizing: Move west border | | ![](ne_resize_cursor.png) | "ne-resize" | Resizing: Move north-east corner | | ![](nw_resize_cursor.png) | "nw-resize" | Resizing: Move north-west corner | | ![](sw_resize_cursor.png) | "sw-resize" | Resizing: Move south-west corner | | ![](se_resize_cursor.png) | "se-resize" | Resizing: Move south-east corner | | ![](col_resize_cursor.png) | "col-resize" | Resizing: Move an item or border horizontally | | ![](row_resize_cursor.png) | "row-resize" | Resizing: Move an item or border vertically | | ![](ew_resize_cursor.png) | "ew-resize" | Moving: Something can be moved horizontally | | ![](ns_resize_cursor.png) | "ns-resize" | Moving: Something can be moved vertically | | ![](nesw_resize_cursor.png) | "nesw-resize" | Moving: Something can be moved diagonally, north-east to south-west | | ![](nwse_resize_cursor.png) | "nwse-resize" | Moving: something can be moved diagonally, north-west to south-east | | ![](all_resize_cursor.png) | "all-resize" | Moving: Something can be moved in any direction | | ![](all_scroll_cursor.png) | "all-scroll" | Can scroll in any direction | | ![](zoom_in_cursor.png) | "zoom-in" | Zoom in | | ![](zoom_out_cursor.png) | "zoom-out" | Zoom out |

name

Passed: a string.

the name of the cursor

fallback

Passed, or left out: a <GdkCursor>, or #f.

#f or the <GdkCursor> to fall back to when this one cannot be supported

%return

Returned: a <GdkCursor>, or #f.

a new <GdkCursor>, or #f if there is no cursor with the given name

Procedure: cursor:new-from-texture texture hotspot-x hotspot-y [fallback] ⇒ %return

Creates a new cursor from a <GdkTexture>.

texture

Passed: a <GdkTexture>.

the texture providing the pixel data

hotspot-x

Passed: a 32-bit integer.

the horizontal offset of the “hotspot” of the cursor

hotspot-y

Passed: a 32-bit integer.

the vertical offset of the “hotspot” of the cursor

fallback

Passed, or left out: a <GdkCursor>, or #f.

the <GdkCursor> to fall back to when this one cannot be supported

%return

Returned: a <GdkCursor>.

a new <GdkCursor>