ShortcutController
open class ShortcutController : EventController, ShortcutControllerProtocol
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 ShortcutController
type acts as a reference-counted owner of an underlying GtkShortcutController
instance.
It provides the methods that can operate on this data type through ShortcutControllerProtocol
conformance.
Use ShortcutController
as a strong reference or owner of a GtkShortcutController
instance.
-
Designated initialiser from the underlying `C` data type.
This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the
ShortcutController
instance.Declaration
Swift
@inlinable public init(_ op: UnsafeMutablePointer<GtkShortcutController>)
Parameters
op
pointer to the underlying object
-
Designated initialiser from a constant pointer to the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theShortcutController
instance.Declaration
Swift
@inlinable public init(_ op: UnsafePointer<GtkShortcutController>)
Parameters
op
pointer to the underlying object
-
Optional initialiser from a non-mutating
gpointer
to the underlyingC
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theShortcutController
instance.Declaration
Swift
@inlinable override public init!(gpointer op: gpointer?)
Parameters
op
gpointer to the underlying object
-
Optional initialiser from a non-mutating
gconstpointer
to the underlyingC
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theShortcutController
instance.Declaration
Swift
@inlinable override public init!(gconstpointer op: gconstpointer?)
Parameters
op
pointer to the underlying object
-
Optional initialiser from a constant pointer to the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theShortcutController
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafePointer<GtkShortcutController>?)
Parameters
op
pointer to the underlying object
-
Optional initialiser from the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theShortcutController
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafeMutablePointer<GtkShortcutController>?)
Parameters
op
pointer to the underlying object
-
Designated initialiser from the underlying
C
data type. Will retainGtkShortcutController
. i.e., ownership is transferred to theShortcutController
instance.Declaration
Swift
@inlinable public init(retaining op: UnsafeMutablePointer<GtkShortcutController>)
Parameters
op
pointer to the underlying object
-
Reference intialiser for a related type that implements
ShortcutControllerProtocol
Will retainGtkShortcutController
.Declaration
Swift
@inlinable public init<T>(shortcutController other: T) where T : ShortcutControllerProtocol
Parameters
other
an instance of a related type that implements
ShortcutControllerProtocol
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ShortcutControllerProtocol
.Declaration
Swift
@inlinable override public init<T>(cPointer p: UnsafeMutablePointer<T>)
Parameters
cPointer
pointer to the underlying object
-
Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ShortcutControllerProtocol
.Declaration
Swift
@inlinable override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)
Parameters
cPointer
pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ShortcutControllerProtocol
.Declaration
Swift
@inlinable override public init(raw p: UnsafeRawPointer)
Parameters
p
raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ShortcutControllerProtocol
.Declaration
Swift
@inlinable override public init(retainingRaw 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 public required init(raw p: UnsafeMutableRawPointer)
Parameters
p
mutable raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ShortcutControllerProtocol
.Declaration
Swift
@inlinable required public init(retainingRaw raw: UnsafeMutableRawPointer)
Parameters
raw
mutable raw pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ShortcutControllerProtocol
.Declaration
Swift
@inlinable override public init(opaquePointer p: OpaquePointer)
Parameters
p
opaque pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ShortcutControllerProtocol
.Declaration
Swift
@inlinable override public init(retainingOpaquePointer p: OpaquePointer)
Parameters
p
opaque pointer to the underlying object
-
Creates a new shortcut controller.
Declaration
Swift
@inlinable public 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 public 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 public static func newFor<ListModelT>(model: ListModelT) -> EventController! where ListModelT : ListModelProtocol