ShortcutController

gtk.shortcut_controller.ShortcutController is an event controller that manages shortcuts.

Most common shortcuts are using this controller implicitly, e.g. by adding a mnemonic underline to a gtk.label.Label, or by installing a key binding using gtk.widget_class.WidgetClass.addBinding, or by adding accelerators to global actions using gtk.application.Application.setAccelsForAction.

But it is possible to create your own shortcut controller, and add shortcuts to it.

gtk.shortcut_controller.ShortcutController implements gio.list_model.ListModel for querying the shortcuts that have been added to it.

GtkShortcutController as GtkBuildable

gtk.shortcut_controller.ShortcutControllers can be created in gtk.builder.Builder ui files, to set up shortcuts in the same place as the widgets.

An example of a UI definition fragment with gtk.shortcut_controller.ShortcutController:

<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 gtk.activate_action.ActivateAction for triggering the activate signal of the gtk.button.Button. See gtk.shortcut_action.ShortcutAction.parseString for the syntax for other kinds of gtk.shortcut_action.ShortcutAction. See gtk.shortcut_trigger.ShortcutTrigger.parseString to learn more about the syntax for triggers.

Constructors

this
this()

Creates a new shortcut controller.

Members

Functions

addShortcut
void addShortcut(gtk.shortcut.Shortcut shortcut)

Adds shortcut to the list of shortcuts handled by self.

getMnemonicsModifiers
gdk.types.ModifierType getMnemonicsModifiers()

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

getScope
gtk.types.ShortcutScope getScope()

Gets the scope for when this controller activates its shortcuts.

removeShortcut
void removeShortcut(gtk.shortcut.Shortcut shortcut)

Removes shortcut from the list of shortcuts handled by self.

setMnemonicsModifiers
void setMnemonicsModifiers(gdk.types.ModifierType modifiers)

Sets the controller to use the given modifier for mnemonics.

setScope
void setScope(gtk.types.ShortcutScope scope_)

Sets the controller to have the given scope.

Static functions

newForModel
gtk.shortcut_controller.ShortcutController newForModel(gio.list_model.ListModel model)

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

Mixed In Members

From mixin ListModelT!()

getItem
T getItem(uint position)

Get the item at position and cast to the template type. NOTE: If type is an interface and no known D object is found that the object conforms to, the interface IfaceProxy object will be used. If position is greater than the number of items in list, %NULL is returned. %NULL may be returned if index is smaller than the length of the list, but the object does not conform to the template type. This function is meant to be used by language bindings in place of Gio.ListModel.getItem. See also: Gio.ListModel.getNItems

getItemType
gobject.types.GType getItemType()

Gets the type of the items in list.

getNItems
uint getNItems()

Gets the number of items in list.

getItem
gobject.object.ObjectG getItem(uint position)

Get the item at position.

itemsChanged
void itemsChanged(uint position, uint removed, uint added)

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

connectItemsChanged
ulong connectItemsChanged(T callback, Flag!"After" after)

Connect to ItemsChanged signal.

From mixin BuildableT!()

getBuildableId
string getBuildableId()

Gets the ID of the buildable object.

Inherited Members

From EventController

getCurrentEvent
gdk.event.Event getCurrentEvent()

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

getCurrentEventDevice
gdk.device.Device getCurrentEventDevice()

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

getCurrentEventState
gdk.types.ModifierType getCurrentEventState()

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

getCurrentEventTime
uint getCurrentEventTime()

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

getName
string getName()

Gets the name of controller.

getPropagationLimit
gtk.types.PropagationLimit getPropagationLimit()

Gets the propagation limit of the event controller.

getPropagationPhase
gtk.types.PropagationPhase getPropagationPhase()

Gets the propagation phase at which controller handles events.

getWidget
gtk.widget.Widget getWidget()

Returns the gtk.widget.Widget this controller relates to.

reset
void reset()

Resets the controller to a clean state.

setName
void setName(string name)

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

setPropagationLimit
void setPropagationLimit(gtk.types.PropagationLimit limit)

Sets the event propagation limit on the event controller.

setPropagationPhase
void setPropagationPhase(gtk.types.PropagationPhase phase)

Sets the propagation phase at which a controller handles events.

setStaticName
void setStaticName(string name)

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

From ListModel

getItem
T getItem(uint position)

Get the item at position and cast to the template type. NOTE: If type is an interface and no known D object is found that the object conforms to, the interface IfaceProxy object will be used. If position is greater than the number of items in list, %NULL is returned. %NULL may be returned if index is smaller than the length of the list, but the object does not conform to the template type. This function is meant to be used by language bindings in place of Gio.ListModel.getItem. See also: Gio.ListModel.getNItems

getItemType
gobject.types.GType getItemType()

Gets the type of the items in list.

getNItems
uint getNItems()

Gets the number of items in list.

getItem
gobject.object.ObjectG getItem(uint position)

Get the item at position.

itemsChanged
void itemsChanged(uint position, uint removed, uint added)

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

connectItemsChanged
ulong connectItemsChanged(T callback, Flag!"After" after)

Connect to ItemsChanged signal.

From Buildable

getBuildableId
string getBuildableId()

Gets the ID of the buildable object.