ShortcutController
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 class@Gtk.Label, or by installing a key binding using method@Gtk.WidgetClass.add_binding, or by adding accelerators to global actions using method@Gtk.Application.set_accels_for_action.
But it is possible to create your own shortcut controller, and add shortcuts to it.
GtkShortcutController
implements iface@Gio.ListModel for querying the shortcuts that have been added to it.
GtkShortcutController as GtkBuildable
GtkShortcutController
s can be created in class@Gtk.Builder 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 class@Gtk.ActivateAction for triggering the activate
signal of the class@Gtk.Button. See ctor@Gtk.ShortcutAction.parse_string for the syntax for other kinds of class@Gtk.ShortcutAction. See ctor@Gtk.ShortcutTrigger.parse_string to learn more about the syntax for triggers.
Skipped during bindings generation
method
item-type
: Property has no getter nor settermethod
model
: Property has no getter nor settermethod
n-items
: Property has no getter nor setter
Constructors
Properties
The modifiers that need to be pressed to allow mnemonics activation.
The limit for which events this controller will handle.
The propagation phase at which this controller will handle events.
What scope the shortcuts will be handled in.
Functions
Adds @shortcut to the list of shortcuts handled by @self.
Gets the ID of the @buildable object.
Returns the event that is currently being handled by the controller.
Returns the device of the event that is currently being handled by the controller.
Returns the modifier state of the event that is currently being handled by the controller.
Returns the timestamp of the event that is currently being handled by the controller.
Gets the mnemonics modifiers for when this controller activates its shortcuts.
Gets the propagation limit of the event controller.
Gets the propagation phase at which @controller handles events.
Gets the scope for when this controller activates its shortcuts.
Removes @shortcut from the list of shortcuts handled by @self.
Sets the controller to use the given modifier for mnemonics.
Sets the event propagation limit on the event controller.
Sets the propagation phase at which a controller handles events.
Sets the controller to have the given @scope.
Sets a name on the controller that can be used for debugging.