gtk.shortcut_controller
Module for [ShortcutController] class
Types 3
[gtk.shortcut_controller.ShortcutController] is an event controller that manages shortcuts.
Most common shortcuts are using this controller implicitly, e.g. by adding a mnemonic underline to a [gtk.label.Label], or by installing a key binding using [gtk.widget_class.WidgetClass.addBinding], or by adding accelerators to global actions using [gtk.application.Application.setAccelsForAction].
But it is possible to create your own shortcut controller, and add shortcuts to it.
[gtk.shortcut_controller.ShortcutController] implements [gio.list_model.ListModel] for querying the shortcuts that have been added to it.
GtkShortcutController as GtkBuildable
[gtk.shortcut_controller.ShortcutController]s can be created in [gtk.builder.Builder] ui files, to set up shortcuts in the same place as the widgets.
An example of a UI definition fragment with [gtk.shortcut_controller.ShortcutController]:
<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 [gtk.activate_action.ActivateAction] for triggering the activate signal of the [gtk.button.Button]. See [gtk.shortcut_action.ShortcutAction.parseString] for the syntax for other kinds of [gtk.shortcut_action.ShortcutAction]. See [gtk.shortcut_trigger.ShortcutTrigger.parseString] to learn more about the syntax for triggers.
ShortcutController self()Returns `this`, for use in `with` statements.ShortcutControllerGidBuilder builder()Get builder for [gtk.shortcut_controller.ShortcutController] Returns: New builder objectgobject.types.GType itemType() @propertyGet `itemType` property. Returns: The type of items. See [gio.list_model.ListModel.getItemType].gdk.types.ModifierType mnemonicModifiers() @propertyGet `mnemonicModifiers` property. Returns: The modifiers that need to be pressed to allow mnemonics activation.void mnemonicModifiers(gdk.types.ModifierType propval) @propertySet `mnemonicModifiers` property. Params: propval = The modifiers that need to be pressed to allow mnemonics activation.uint nItems() @propertyGet `nItems` property. Returns: The number of items. See [gio.list_model.ListModel.getNItems].gtk.types.ShortcutScope scope_() @propertyGet `scope_` property. Returns: What scope the shortcuts will be handled in.void scope_(gtk.types.ShortcutScope propval) @propertySet `scope_` property. Params: propval = What scope the shortcuts will be handled in.gtk.shortcut_controller.ShortcutController newForModel(gio.list_model.ListModel model)Creates a new shortcut controller that takes its shortcuts from the given list model.void addShortcut(gtk.shortcut.Shortcut shortcut)Adds shortcut to the list of shortcuts handled by self.gdk.types.ModifierType getMnemonicsModifiers()Gets the mnemonics modifiers for when this controller activates its shortcuts. Returns: the controller's mnemonics modifiersgtk.types.ShortcutScope getScope()Gets the scope for when this controller activates its shortcuts.void removeShortcut(gtk.shortcut.Shortcut shortcut)Removes shortcut from the list of shortcuts handled by self.void setMnemonicsModifiers(gdk.types.ModifierType modifiers)Sets the controller to use the given modifier for mnemonics.void setScope(gtk.types.ShortcutScope scope_)Sets the controller to have the given scope.T mnemonicModifiers(gdk.types.ModifierType propval)Set `mnemonicModifiers` property. Params: propval = The modifiers that need to be pressed to allow mnemonics activation. Returns: Builder instance for fluent chainingT model(gio.list_model.ListModel propval)Set `model` property. Params: propval = A list model to take shortcuts from. Returns: Builder instance for fluent chainingT scope_(gtk.types.ShortcutScope propval)Set `scope_` property. Params: propval = What scope the shortcuts will be handled in. Returns: Builder instance for fluent chainingFluent builder for [gtk.shortcut_controller.ShortcutController]