CursorProtocol

public protocol CursorProtocol : ObjectProtocol

The CursorProtocol protocol exposes the methods and properties of an underlying GdkCursor instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see Cursor. Alternatively, use CursorRef as a lighweight, unowned reference if you already have an instance you just want to use.

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 [methodGdk.Surface.set_cursor] or [methodGdk.Surface.set_device_cursor]. Applications will typically use higher-level GTK functions such as [methodGtk.Widget.set_cursor]` instead.

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

  • ptr

    Untyped pointer to the underlying GdkCursor instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • cursor_ptr Default implementation

    Typed pointer to the underlying GdkCursor instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GdkCursor instance.

    Declaration

    Swift

    var cursor_ptr: UnsafeMutablePointer<GdkCursor>! { get }
  • Required Initialiser for types conforming to CursorProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

Cursor Class

  • Bind a CursorPropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: CursorPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol

    Parameters

    source_property

    the source property to bind

    target

    the target object to bind to

    target_property

    the target property to bind to

    flags

    the flags to pass to the Binding

    transform_from

    ValueTransformer to use for forward transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a Cursor property

    Declaration

    Swift

    @inlinable
    func get(property: CursorPropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    Set the value of a Cursor property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: CursorPropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

Cursor Class: CursorProtocol extension (methods and fields)

  • getFallback() Extension method

    Returns the fallback for this cursor.

    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.

    Declaration

    Swift

    @inlinable
    func getFallback() -> CursorRef!
  • getHotspotX() Extension method

    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 [ctorGdk.Cursor.new_from_texture].

    Declaration

    Swift

    @inlinable
    func getHotspotX() -> Int
  • getHotspotY() Extension method

    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 [ctorGdk.Cursor.new_from_texture].

    Declaration

    Swift

    @inlinable
    func getHotspotY() -> Int
  • getName() Extension method

    Returns the name of the cursor.

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

    Declaration

    Swift

    @inlinable
    func getName() -> String!
  • getTexture() Extension method

    Returns the texture for the cursor.

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

    Declaration

    Swift

    @inlinable
    func getTexture() -> TextureRef!
  • fallback Extension method

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

    Declaration

    Swift

    @inlinable
    var fallback: CursorRef! { get }
  • hotspotX Extension method

    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 [ctorGdk.Cursor.new_from_texture].

    Declaration

    Swift

    @inlinable
    var hotspotX: Int { get }
  • hotspotY Extension method

    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 [ctorGdk.Cursor.new_from_texture].

    Declaration

    Swift

    @inlinable
    var hotspotY: Int { get }
  • name Extension method

    Name of this this cursor.

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

    Declaration

    Swift

    @inlinable
    var name: String! { get }
  • texture Extension method

    The texture displayed by this cursor.

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

    Declaration

    Swift

    @inlinable
    var texture: TextureRef! { get }