### Class

# Gtk ShortcutController

since: 4.0

#### Description [src]

    final class Gtk.ShortcutController : Gtk.EventController
      implements Gio.ListModel, Gtk.Buildable {
      /* 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 GtkBuildable

`GtkShortcutController`s can be created in `GtkBuilder` 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.

Available since: 4.0

#### Ancestors

- GtkEventController
- GObject

#### Implements

- GListModel
- GtkBuildable

#### Constructors

###### gtk_shortcut_controller_new

Creates a new shortcut controller.

since: 4.0

###### gtk_shortcut_controller_new_for_model

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

since: 4.0

#### Instance methods

###### gtk_shortcut_controller_add_shortcut

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

since: 4.0

###### gtk_shortcut_controller_get_mnemonics_modifiers

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

since: 4.0

###### gtk_shortcut_controller_get_scope

Gets the scope for when this controller activates its shortcuts.

since: 4.0

###### gtk_shortcut_controller_remove_shortcut

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

since: 4.0

###### gtk_shortcut_controller_set_mnemonics_modifiers

Sets the controller to use the given modifier for mnemonics.

since: 4.0

###### gtk_shortcut_controller_set_scope

Sets the controller to have the given `scope`.

since: 4.0

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

###### gtk_event_controller_get_current_event

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

since: 4.0

###### gtk_event_controller_get_current_event_device

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

since: 4.0

###### gtk_event_controller_get_current_event_state

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

since: 4.0

###### gtk_event_controller_get_current_event_time

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

since: 4.0

###### gtk_event_controller_get_name

Gets the name of `controller`.

since: 4.0

###### gtk_event_controller_get_propagation_limit

Gets the propagation limit of the event controller.

since: 4.0

###### gtk_event_controller_get_propagation_phase

Gets the propagation phase at which `controller` handles events.

since: 4.0

###### gtk_event_controller_get_widget

Returns the `GtkWidget` this controller relates to.

since: 4.0

###### gtk_event_controller_reset

Resets the `controller` to a clean state.

since: 4.0

###### gtk_event_controller_set_name

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

since: 4.0

###### gtk_event_controller_set_propagation_limit

Sets the event propagation limit on the event controller.

since: 4.0

###### gtk_event_controller_set_propagation_phase

Sets the propagation phase at which a controller handles events.

since: 4.0

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

since: 4.0

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

since: 4.0

###### Gtk.ShortcutController:model

A list model to take shortcuts from.

since: 4.0

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

since: 4.0

##### Properties inherited from GtkEventController (4)

###### Gtk.EventController:name

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

since: 4.0

###### Gtk.EventController:propagation-limit

The limit for which events this controller will handle.

since: 4.0

###### Gtk.EventController:propagation-phase

The propagation phase at which this controller will handle events.

since: 4.0

###### Gtk.EventController:widget

The widget receiving the `GdkEvents` that the controller will handle.

since: 4.0

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

since: 2.0

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