class Gdk::Cursor

Overview

Gdk::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#cursor= or Gdk::Surface#device_cursor=. Applications will typically use higher-level GTK functions such as Gtk::Widget#cursor= instead.

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

Defined in:

lib/gi-crystal/src/auto/gdk-4.0/cursor.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class GObject::Object

bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void)? data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void)? qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void)?) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void)? steal_data, steal_qdata(quark : UInt32) : Pointer(Void)? steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, cast?(obj : GObject::Object) : self? cast?, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

compat_control(what : UInt64, data : Pointer(Void)?) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Constructor Detail

def self.new #

Initialize a new Cursor.


def self.new(*, fallback : Gdk::Cursor? = nil, hotspot_x : Int32? = nil, hotspot_y : Int32? = nil, name : String? = nil, texture : Gdk::Texture? = nil) #

def self.new_from_name(name : String, fallback : Gdk::Cursor?) : self? #

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" | "default" | "help" | "pointer" | | "context-menu" | "progress" | "wait" | "cell" | | "crosshair" | "text" | "vertical-text" | "alias" | | "copy" | "no-drop" | "move" | "not-allowed" | | "grab" | "grabbing" | "all-scroll" | "col-resize" | | "row-resize" | "n-resize" | "e-resize" | "s-resize" | | "w-resize" | "ne-resize" | "nw-resize" | "sw-resize" | | "se-resize" | "ew-resize" | "ns-resize" | "nesw-resize" | | "nwse-resize" | "zoom-in" | "zoom-out" | |


def self.new_from_texture(texture : Gdk::Texture, hotspot_x : Int32, hotspot_y : Int32, fallback : Gdk::Cursor?) : self #

Creates a new cursor from a Gdk::Texture.


Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


Instance Method Detail

def fallback : Gdk::Cursor? #

Returns the fallback for this @cursor.

The fallback will be used if this cursor is not available on a given Gdk::Display. 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 Gdk::Display it is used on does not support textured cursors.


def fallback=(value : Gdk::Cursor?) : Gdk::Cursor? #

def hotspot_x : Int32 #

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 Gdk::Cursor#new_from_texture.


def hotspot_x=(value : Int32) : Int32 #

def hotspot_y : Int32 #

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 Gdk::Cursor#new_from_texture.


def hotspot_y=(value : Int32) : Int32 #

def name : String? #

Returns the name of the cursor.

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


def name=(value : String) : String #

def texture : Gdk::Texture? #

Returns the texture for the cursor.

If the cursor is a named cursor, nil will be returned.


def texture=(value : Gdk::Texture?) : Gdk::Texture? #