Basics
Guides
API Reference
Basics
Guides
API Reference
[253:14] static extends: object
Alternate constructors for ShortcutController. Usage:
ShortcutControllerCtors.<name>(...). The primary constructor lives
directly on ShortcutController.
newForModel (object model)
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.
model is a GListModel containing shortcuts.A new ShortcutController.[32:7] extends: object
Manages keyboard shortcuts and their activation. 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
GtkShortcutControllers 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: xml <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.
ShortcutController ()
Creates a new shortcut controller.
toNativeHandle (Source)
Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from
fn.call(...), another generated wrapper exposinghandle(), or null. Returns null when the argument carries no pointer.
Source is the raw handle, raw buffer, wrapper, or null.A raw pointer carrier or null when no pointer is present.getLib ()
Returns the opened native library for this generated wrapper.
The opened native library.handle ()
Returns the wrapped NativeHandle.
The wrapped NativeHandle.isNull ()
Returns true when the wrapped handle is null.
A bool.describe ()
Returns a small string for debugging generated wrappers.
A string.asEventController ()
Wraps this handle as
EventController.
A EventController object.asListModel ()
Wraps this handle as
ListModel.
A ListModel object.asBuildable ()
Wraps this handle as
Buildable.
A Buildable object.getProperty (string Name)
Reads one generated property by name.
setProperty (string Name, Value)
Writes one generated property by name.
setMnemonicmodifiers (string Value)
The modifiers that need to be pressed to allow mnemonics activation.
Value is the new property value.None.setScope (string Value)
What scope the shortcuts will be handled in.
Value is the new property value.None.add_shortcut (object shortcut)
Adds @shortcut to the list of shortcuts handled by @self. If this controller uses an external shortcut list, this function does nothing.
shortcut is a GtkShortcut.None.get_mnemonics_modifiers ()
Gets the mnemonics modifiers for when this controller activates its shortcuts.
get_scope ()
Gets the scope for when this controller activates its shortcuts. See [method@Gtk.ShortcutController.set_scope] for details.
remove_shortcut (object shortcut)
Removes @shortcut from the list of shortcuts handled by @self. If
had not been added to @controller or this controller uses an external shortcut list, this function does nothing.shortcut is a GtkShortcut.None.set_mnemonics_modifiers (string modifiers)
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
GtkPopoverMenus, 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.
modifiers is the new mnemonics_modifiers to use.None.set_scope (string scope)
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 %GTK_SHORTCUT_SCOPE_LOCAL, shortcuts will only be activated when the widget has focus.
scope is the new scope to use.None.[273:14] static extends: object
Generated metadata helpers for ShortcutController class surfaces.
properties ()
Returns property metadata for
ShortcutController.
A list.
Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.