ShortcutController

class ShortcutController(**properties: Any)

Superclasses: EventController, Object

Implemented Interfaces: ListModel, Buildable

Constructors:

ShortcutController(**properties)
new() -> Gtk.EventController
new_for_model(model:Gio.ListModel) -> Gtk.EventController

Constructors

class ShortcutController
classmethod new() EventController

Creates a new shortcut controller.

classmethod new_for_model(model: ListModel) EventController

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.

Parameters:

model – a GListModel containing shortcuts

Methods

class ShortcutController
add_shortcut(shortcut: Shortcut) None

Adds shortcut to the list of shortcuts handled by self.

If this controller uses an external shortcut list, this function does nothing.

Parameters:

shortcut – a GtkShortcut

get_mnemonics_modifiers() ModifierType

Gets the mnemonics modifiers for when this controller activates its shortcuts.

get_scope() ShortcutScope

Gets the scope for when this controller activates its shortcuts.

See set_scope for details.

remove_shortcut(shortcut: Shortcut) None

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.

Parameters:

shortcut – a GtkShortcut

set_mnemonics_modifiers(modifiers: ModifierType) None

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.

Parameters:

modifiers – the new mnemonics_modifiers to use

set_scope(scope: ShortcutScope) None

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.

Parameters:

scope – the new scope to use

Properties

class ShortcutController
props.item_type: type

The type of items. See get_item_type.

Added in version 4.8.

props.mnemonic_modifiers: ModifierType

The modifiers that need to be pressed to allow mnemonics activation.

props.model: ListModel

A list model to take shortcuts from.

props.n_items: int

The number of items. See get_n_items.

Added in version 4.8.

props.scope: ShortcutScope

What scope the shortcuts will be handled in.