CursorRef

public struct CursorRef : CursorProtocol, GWeakCapturing

The CursorRef type acts as a lightweight Swift reference to an underlying GdkCursor instance. It exposes methods that can operate on this data type through CursorProtocol conformance. Use CursorRef only as an unowned reference to an existing GdkCursor instance.

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.
    

    For type-safe access, use the generated, typed pointer cursor_ptr property instead.

    Declaration

    Swift

    public let ptr: UnsafeMutableRawPointer!

Cursor Class

  • Designated initialiser from the underlying C data type

    Declaration

    Swift

    @inlinable
    init(_ p: UnsafeMutablePointer<GdkCursor>)
  • Designated initialiser from a constant pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init(_ p: UnsafePointer<GdkCursor>)
  • Conditional initialiser from an optional pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init!(_ maybePointer: UnsafeMutablePointer<GdkCursor>?)
  • Conditional initialiser from an optional, non-mutable pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init!(_ maybePointer: UnsafePointer<GdkCursor>?)
  • Conditional initialiser from an optional gpointer

    Declaration

    Swift

    @inlinable
    init!(gpointer g: gpointer?)
  • Conditional initialiser from an optional, non-mutable gconstpointer

    Declaration

    Swift

    @inlinable
    init!(gconstpointer g: gconstpointer?)
  • Reference intialiser for a related type that implements CursorProtocol

    Declaration

    Swift

    @inlinable
    init<T>(_ other: T) where T : CursorProtocol
  • This factory is syntactic sugar for setting weak pointers wrapped in GWeak<T>

    Declaration

    Swift

    @inlinable
    static func unowned<T>(_ other: T) -> CursorRef where T : CursorProtocol
  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to CursorProtocol.

    Declaration

    Swift

    @inlinable
    init<T>(cPointer: UnsafeMutablePointer<T>)
  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to CursorProtocol.

    Declaration

    Swift

    @inlinable
    init<T>(constPointer: UnsafePointer<T>)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to CursorProtocol.

    Declaration

    Swift

    @inlinable
    init(mutating raw: UnsafeRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to CursorProtocol.

    Declaration

    Swift

    @inlinable
    init(raw: UnsafeMutableRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to CursorProtocol.

    Declaration

    Swift

    @inlinable
    init(opaquePointer: OpaquePointer)
  • 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”

    Declaration

    Swift

    @inlinable
    init<CursorT>(name: UnsafePointer<CChar>!, fallback: CursorT?) where CursorT : CursorProtocol
  • Creates a new cursor from a GdkTexture.

    Declaration

    Swift

    @inlinable
    init<CursorT, TextureT>(texture: TextureT, hotspotX: Int, hotspotY: Int, fallback: CursorT?) where CursorT : CursorProtocol, TextureT : TextureProtocol
  • 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”

    Declaration

    Swift

    @inlinable
    static func newFrom<CursorT>(name: UnsafePointer<CChar>!, fallback: CursorT?) -> CursorRef! where CursorT : CursorProtocol
  • Creates a new cursor from a GdkTexture.

    Declaration

    Swift

    @inlinable
    static func newFrom<CursorT, TextureT>(texture: TextureT, hotspotX: Int, hotspotY: Int, fallback: CursorT?) -> CursorRef! where CursorT : CursorProtocol, TextureT : TextureProtocol