Class

Gtk.ShortcutController

Description [src]

final class Gtk.ShortcutController : Gtk.EventController {
  /* No available fields */
}

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 gtk_widget_class_add_binding(), or by adding accelerators to global actions using 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'>&amp;lt;Control&amp;gt;k</property>
            <property name='action'>activate</property>
          </object>
        </child>
      </object>
    </child>
  </object>

This example creates a GtkActivateAction for triggering the activate signal of the GtkButton. See gtk_shortcut_action_parse_string() for the syntax for other kinds of GtkShortcutAction. See gtk_shortcut_trigger_parse_string() to learn more about the syntax for triggers.

Hierarchy

Hierarchy for Gtk.ShortcutController

Ancestors

Implements

Constructors

gtk_shortcut_controller_new

Creates a new shortcut controller.

gtk_shortcut_controller_new_for_model

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

Instance methods

gtk_shortcut_controller_add_shortcut

Adds shortcut to the list of shortcuts handled by self.

gtk_shortcut_controller_get_mnemonics_modifiers

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

gtk_shortcut_controller_get_scope

Gets the scope for when this controller activates its shortcuts. See gtk_shortcut_controller_set_scope() for details.

gtk_shortcut_controller_remove_shortcut

Removes shortcut from the list of shortcuts handled by self.

gtk_shortcut_controller_set_mnemonics_modifiers

Sets the controller to have the given mnemonics_modifiers.

gtk_shortcut_controller_set_scope

Sets the controller to have the given scope.

Methods inherited from GtkEventController (12)
gtk_event_controller_get_current_event

Returns the event that is currently being handled by the controller, and NULL at other times.

gtk_event_controller_get_current_event_device

Returns the device of the event that is currently being handled by the controller, and NULL otherwise.

gtk_event_controller_get_current_event_state

Returns the modifier state of the event that is currently being handled by the controller, and 0 otherwise.

gtk_event_controller_get_current_event_time

Returns the timestamp of the event that is currently being handled by the controller, and 0 otherwise.

gtk_event_controller_get_name

Gets the name of controller.

gtk_event_controller_get_propagation_limit

Gets the propagation limit of the event controller.

gtk_event_controller_get_propagation_phase

Gets the propagation phase at which controller handles events.

gtk_event_controller_get_widget

Returns the GtkWidget this controller relates to.

gtk_event_controller_reset

Resets the controller to a clean state.

gtk_event_controller_set_name

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

gtk_event_controller_set_propagation_limit

Sets the event propagation limit on the event controller.

gtk_event_controller_set_propagation_phase

Sets the propagation phase at which a controller handles events.

Methods inherited from GtkBuildable (1)
gtk_buildable_get_buildable_id

Gets the ID of the buildable object.

Properties

Gtk.ShortcutController:mnemonic-modifiers

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

Gtk.ShortcutController:model

A list model to take shortcuts from.

Gtk.ShortcutController:scope

What scope the shortcuts will be handled in.

Properties inherited from GtkEventController (4)
Gtk.EventController:name

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

Gtk.EventController:propagation-limit

The limit for which events this controller will handle.

Gtk.EventController:propagation-phase

The propagation phase at which this controller will handle events.

Gtk.EventController:widget

The widget receiving the GdkEvents that the controller will handle.

Class structure

struct GtkShortcutControllerClass {
  /* no available fields */
}