Gtk.ShortcutController
Description: Reference for Gtk.ShortcutController

### Class

# GtkShortcutController

#### 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'>&lt;Control&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.

#### Ancestors

- GtkEventController
- GObject

#### Implements

- GListModel
- GtkBuildable

#### 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.

###### 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 use the given modifier for mnemonics.

###### gtk_shortcut_controller_set_scope

Sets the controller to have the given `scope`.

##### Methods inherited from GtkEventController (13)

###### gtk_event_controller_get_current_event

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

###### gtk_event_controller_get_current_event_device

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

###### gtk_event_controller_get_current_event_state

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

###### gtk_event_controller_get_current_event_time

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

###### 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.

###### gtk_event_controller_set_static_name

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

since: 4.8

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

##### Methods inherited from GListModel (5)

###### g_list_model_get_item

Get the item at `position`.

since: 2.44

###### g_list_model_get_item_type

Gets the type of the items in `list`.

since: 2.44

###### g_list_model_get_n_items

Gets the number of items in `list`.

since: 2.44

###### g_list_model_get_object

Get the item at `position`.

since: 2.44

###### g_list_model_items_changed

Emits the `GListModel::items-changed` signal on `list`.

since: 2.44

##### Methods inherited from GtkBuildable (1)

###### gtk_buildable_get_buildable_id

Gets the ID of the `buildable` object.

#### Properties

###### Gtk.ShortcutController:item-type

The type of items. See `g_list_model_get_item_type()`.

since: 4.8

###### 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:n-items

The number of items. See `g_list_model_get_n_items()`.

since: 4.8

###### 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.

#### Signals

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

##### Signals inherited from GListModel (1)

###### GListModel::items-changed

This signal is emitted whenever items were added to or removed from `list`. At `position`, `removed` items were removed and `added` items were added in their place.

since: 2.44

#### Class structure

    struct GtkShortcutControllerClass {
      /* no available fields */
    }

No description available.