It derives from <GtkEventController>.
Manages keyboard shortcuts and their activation.
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 Gtk.WidgetClass.add_binding, or by
adding accelerators to global actions using 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>s can be created
in <GtkBuilder> 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 <GtkActivateAction>
for triggering the activate signal of the
<GtkButton>. See shortcut-action:parse-string for the syntax for other
kinds of <GtkShortcutAction>. See
shortcut-trigger:parse-string
to learn more about the syntax for triggers.
The type of items. See list-model:get-item-type.
Its value is a class, or a GType number.
It is read only.
The modifiers that need to be pressed to allow mnemonics activation.
Its value is a <GdkModifierType> (or, to
set it, a list of its symbols, or one of them).
Set it with (set! (shortcut-controller:mnemonic-modifiers self)
value).
A list model to take shortcuts from.
Its value is a <GListModel>, or #f.
It can only be set when the object is made, with #:model. It
cannot be read.
The number of items. See list-model:get-n-items.
Its value is an unsigned 32-bit integer.
It is read only.
What scope the shortcuts will be handled in.
Its value is a <GtkShortcutScope> (or, to
set it, one of its symbols).
Set it with (set! (shortcut-controller:scope self) value).
Adds shortcut to the list of shortcuts handled by self.
If this controller uses an external shortcut list, this function does nothing.
Passed: a <GtkShortcutController>.
the controller
Passed: a <GtkShortcut>.
Gets the mnemonics modifiers for when this controller activates its shortcuts.
Passed: a <GtkShortcutController>.
Returned: a <GdkModifierType>.
the controller’s mnemonics modifiers
Gets the scope for when this controller activates its shortcuts.
See shortcut-controller:set-scope for details.
Passed: a <GtkShortcutController>.
Returned: a <GtkShortcutScope>.
the controller’s scope
Creates a new shortcut controller.
Returned: a <GtkEventController>.
a newly created shortcut controller
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.
Passed: a <GListModel>.
a <GListModel> containing shortcuts
Returned: a <GtkEventController>.
a newly created shortcut controller
Removes shortcut from the list of shortcuts handled by self.
If shortcut had not been added to controller or this controller uses an external shortcut list, this function does nothing.
Passed: a <GtkShortcutController>.
the controller
Passed: a <GtkShortcut>.
Sets the controller to use the given modifier for mnemonics.
The mnemonics modifiers determines which modifiers need to be pressed to allow activation of shortcuts with mnemonics triggers.
GTK normally uses the Alt modifier for mnemonics, except in
<GtkPopoverMenu>s, where mnemonics can be
triggered without any modifiers. It should be very rarely necessary to
change this, and doing so is likely to interfere with other shortcuts.
This value is only relevant for local shortcut controllers. Global and managed shortcut controllers will have their shortcuts activated from other places which have their own modifiers for activating mnemonics.
Passed: a <GtkShortcutController>.
Passed: a <GdkModifierType>, or a list of
its symbols, or one of them.
the new mnemonics_modifiers to use
Sets the controller to have the given scope.
The scope allows shortcuts to be activated outside of the normal event propagation. In particular, it allows installing global keyboard shortcuts that can be activated even when a widget does not have focus.
With local, shortcuts will only be activated
when the widget has focus.
Passed: a <GtkShortcutController>.
Passed: a <GtkShortcutScope>, or one of its
symbols.
the new scope to use