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.ShortcutControllers 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.
ShortcutControllerGidBuilder builder() static nothrowGet builder for [gtk.shortcut_controller.ShortcutController] Returns: New builder objectgobject.types.GType itemType() @property nothrowGet `itemType` property. Returns: The type of items. See [gio.list_model.ListModel.getItemType].gdk.types.ModifierType mnemonicModifiers() @property nothrowGet `mnemonicModifiers` property. Returns: The modifiers that need to be pressed to allow mnemonics activation.void mnemonicModifiers(gdk.types.ModifierType propval) @property nothrowSet `mnemonicModifiers` property. Params: propval = The modifiers that need to be pressed to allow mnemonics activation.uint nItems() @property nothrowGet `nItems` property. Returns: The number of items. See [gio.list_model.ListModel.getNItems].gtk.types.ShortcutScope scope_() @property nothrowGet `scope_` property. Returns: What scope the shortcuts will be handled in.void scope_(gtk.types.ShortcutScope propval) @property nothrowSet `scope_` property. Params: propval = What scope the shortcuts will be handled in.gtk.shortcut_controller.ShortcutController newForModel(gio.list_model.ListModel model) static nothrowCreates a new shortcut controller that takes its shortcuts from the given list model.void addShortcut(gtk.shortcut.Shortcut shortcut) nothrowAdds shortcut to the list of shortcuts handled by self.gdk.types.ModifierType getMnemonicsModifiers() nothrowGets the mnemonics modifiers for when this controller activates its shortcuts. Returns: the controller's mnemonics modifiersgtk.types.ShortcutScope getScope() nothrowGets the scope for when this controller activates its shortcuts.void removeShortcut(gtk.shortcut.Shortcut shortcut) nothrowRemoves shortcut from the list of shortcuts handled by self.void setMnemonicsModifiers(gdk.types.ModifierType modifiers) nothrowSets the controller to use the given modifier for mnemonics.Fluent builder implementation template for gtk.shortcut_controller.ShortcutController
T mnemonicModifiers(gdk.types.ModifierType propval) nothrowSet `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) nothrowSet `model` property. Params: propval = A list model to take shortcuts from. Returns: Builder instance for fluent chainingT scope_(gtk.types.ShortcutScope propval) nothrowSet `scope_` property. Params: propval = What scope the shortcuts will be handled in. Returns: Builder instance for fluent chainingFluent builder for gtk.shortcut_controller.ShortcutController