ShortcutController

open class ShortcutController(pointer: <Error class: unknown class><<Error class: unknown class>>) : EventController, Buildable

GtkShortcutController is an event controller that manages shortcuts.

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 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 GListModel for querying the shortcuts that have been added to it.

GtkShortcutController as a GtkBuildable

GtkShortcutControllers can be creates in 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'>`&lt;`Control`&gt;`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 GtkButton. See ctor@Gtk.ShortcutAction.parse_string for the syntax for other kinds of GtkShortcutAction. See ctor@Gtk.ShortcutTrigger.parse_string to learn more about the syntax for triggers.

Skipped during bindings generation

  • method mnemonic-modifiers: Property has no getter nor setter

  • method model: Property has no getter nor setter

Constructors

Link copied to clipboard
constructor()

Creates a new shortcut controller.

constructor(model: <Error class: unknown class>)

Creates a new shortcut controller that takes its shortcuts from the given list model.

constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open val gioListModelPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open override val gtkBuildablePointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
val gtkEventControllerPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
val gtkShortcutControllerPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open var name: String?

The name for this controller, typically used for debugging purposes.

Link copied to clipboard

The limit for which events this controller will handle.

Link copied to clipboard

The propagation phase at which this controller will handle events.

Link copied to clipboard

What scope the shortcuts will be handled in.

Link copied to clipboard
open val widget: Widget

The widget receiving the GdkEvents that the controller will handle.

Functions

Link copied to clipboard
open fun addShortcut(shortcut: Shortcut)

Adds @shortcut to the list of shortcuts handled by @self.

Link copied to clipboard
open fun getBuildableId(): String?

Gets the ID of the @buildable object.

Link copied to clipboard
open fun getCurrentEvent(): <Error class: unknown class>?

Returns the event that is currently being handled by the controller.

Link copied to clipboard
open fun getCurrentEventDevice(): <Error class: unknown class>?

Returns the device of the event that is currently being handled by the controller.

Link copied to clipboard
open fun getCurrentEventState(): <Error class: unknown class>

Returns the modifier state of the event that is currently being handled by the controller.

Link copied to clipboard
open fun getCurrentEventTime(): <Error class: unknown class>

Returns the timestamp of the event that is currently being handled by the controller.

Link copied to clipboard
open fun getMnemonicsModifiers(): <Error class: unknown class>

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

Link copied to clipboard
open fun getName(): String?

Gets the name of @controller.

Link copied to clipboard

Gets the propagation limit of the event controller.

Link copied to clipboard

Gets the propagation phase at which @controller handles events.

Link copied to clipboard

Gets the scope for when this controller activates its shortcuts.

Link copied to clipboard
open fun getWidget(): Widget

Returns the GtkWidget this controller relates to.

Link copied to clipboard
open fun removeShortcut(shortcut: Shortcut)

Removes @shortcut from the list of shortcuts handled by @self.

Link copied to clipboard
open fun reset()

Resets the @controller to a clean state.

Link copied to clipboard
open fun setMnemonicsModifiers(modifiers: <Error class: unknown class>)

Sets the controller to use the given modifier for mnemonics.

Link copied to clipboard
open fun setName(name: String? = null)

Sets a name on the controller that can be used for debugging.

Link copied to clipboard

Sets the event propagation limit on the event controller.

Link copied to clipboard

Sets the propagation phase at which a controller handles events.

Link copied to clipboard
open fun setScope(scope: ShortcutScope)

Sets the controller to have the given @scope.