ShortcutControllerRef
public struct ShortcutControllerRef : ShortcutControllerProtocol, GWeakCapturing
GtkShortcutController
is an event controller that manages shortcuts.
Most common shortcuts are using this controller implicitly, e.g. by
adding a mnemonic underline to a GtkLabel
, or by installing a key
binding using [methodGtk.WidgetClass.add_binding
], or by adding accelerators
to global actions using [methodGtk.Application.set_accels_for_action
].
But it is possible to create your own shortcut controller, and add shortcuts to it.
GtkShortcutController
implements GListModel
for querying the
shortcuts that have been added to it.
GtkShortcutController as a GtkBuildable
GtkShortcutControllers
can be creates in ui files to set up
shortcuts in the same place as the widgets.
An example of a UI definition fragment with GtkShortcutController
:
<object class='GtkButton'>
<child>
<object class='GtkShortcutController'>
<property name='scope'>managed</property>
<child>
<object class='GtkShortcut'>
<property name='trigger'><Control>k</property>
<property name='action'>activate</property>
</object>
</child>
</object>
</child>
</object>
This example creates a [classGtk.ActivateAction
] for triggering the
activate
signal of the GtkButton
. See [ctorGtk.ShortcutAction.parse_string
]
for the syntax for other kinds of GtkShortcutAction
. See
[ctorGtk.ShortcutTrigger.parse_string
] to learn more about the syntax
for triggers.
The ShortcutControllerRef
type acts as a lightweight Swift reference to an underlying GtkShortcutController
instance.
It exposes methods that can operate on this data type through ShortcutControllerProtocol
conformance.
Use ShortcutControllerRef
only as an unowned
reference to an existing GtkShortcutController
instance.
-
Untyped pointer to the underlying `GtkShortcutController` instance.
For type-safe access, use the generated, typed pointer
shortcut_controller_ptr
property instead.Declaration
Swift
public let ptr: UnsafeMutableRawPointer!
-
Designated initialiser from the underlying
C
data typeDeclaration
Swift
@inlinable init(_ p: UnsafeMutablePointer<GtkShortcutController>)
-
Designated initialiser from a constant pointer to the underlying
C
data typeDeclaration
Swift
@inlinable init(_ p: UnsafePointer<GtkShortcutController>)
-
Conditional initialiser from an optional pointer to the underlying
C
data typeDeclaration
Swift
@inlinable init!(_ maybePointer: UnsafeMutablePointer<GtkShortcutController>?)
-
Conditional initialiser from an optional, non-mutable pointer to the underlying
C
data typeDeclaration
Swift
@inlinable init!(_ maybePointer: UnsafePointer<GtkShortcutController>?)
-
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
ShortcutControllerProtocol
Declaration
Swift
@inlinable init<T>(_ other: T) where T : ShortcutControllerProtocol
-
This factory is syntactic sugar for setting weak pointers wrapped in
GWeak<T>
Declaration
Swift
@inlinable static func unowned<T>(_ other: T) -> ShortcutControllerRef where T : ShortcutControllerProtocol
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ShortcutControllerProtocol
.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
ShortcutControllerProtocol
.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
ShortcutControllerProtocol
.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
ShortcutControllerProtocol
.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
ShortcutControllerProtocol
.Declaration
Swift
@inlinable init(opaquePointer: OpaquePointer)
-
Creates a new shortcut controller.
Declaration
Swift
@inlinable init()
-
Creates a new shortcut controller that takes its shortcuts from the given list model.
A controller created by this function does not let you add or remove individual shortcuts using the shortcut controller api, but you can change the contents of the model.
Declaration
Swift
@inlinable init<ListModelT>(model: ListModelT) where ListModelT : ListModelProtocol
-
Creates a new shortcut controller that takes its shortcuts from the given list model.
A controller created by this function does not let you add or remove individual shortcuts using the shortcut controller api, but you can change the contents of the model.
Declaration
Swift
@inlinable static func newFor<ListModelT>(model: ListModelT) -> EventControllerRef! where ListModelT : ListModelProtocol