ShortcutController

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

Constructors

this
this(GtkShortcutController* gtkShortcutController, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this()

Creates a new shortcut controller.

this
this(ListModelIF model)

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

Members

Functions

addShortcut
void addShortcut(Shortcut shortcut)

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

getMnemonicsModifiers
GdkModifierType getMnemonicsModifiers()

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

getScope
GtkShortcutScope getScope()

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

getShortcutControllerStruct
GtkShortcutController* getShortcutControllerStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

removeShortcut
void removeShortcut(Shortcut shortcut)

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

setMnemonicsModifiers
void setMnemonicsModifiers(GdkModifierType modifiers)

Sets the controller to have the given @mnemonics_modifiers.

setScope
void setScope(GtkShortcutScope scope_)

Sets the controller to have the given @scope.

Mixins

__anonymous
mixin ListModelT!(GtkShortcutController)
Undocumented in source.
__anonymous
mixin BuildableT!(GtkShortcutController)
Undocumented in source.

Static functions

getType
GType getType()

Variables

gtkShortcutController
GtkShortcutController* gtkShortcutController;

the main Gtk struct

Inherited Members

From EventController

gtkEventController
GtkEventController* gtkEventController;

the main Gtk struct

getEventControllerStruct
GtkEventController* getEventControllerStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

getType
GType getType()
getCurrentEvent
Event getCurrentEvent()

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

getCurrentEventDevice
Device getCurrentEventDevice()

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

getCurrentEventState
GdkModifierType getCurrentEventState()

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

getCurrentEventTime
uint getCurrentEventTime()

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

getName
string getName()

Gets the name of @controller.

getPropagationLimit
GtkPropagationLimit getPropagationLimit()

Gets the propagation limit of the event controller.

getPropagationPhase
GtkPropagationPhase getPropagationPhase()

Gets the propagation phase at which @controller handles events.

getWidget
Widget getWidget()

Returns the #GtkWidget 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(GtkPropagationLimit limit)

Sets the event propagation limit on the event controller.

setPropagationPhase
void setPropagationPhase(GtkPropagationPhase phase)

Sets the propagation phase at which a controller handles events.

From ListModelIF

getListModelStruct
GListModel* getListModelStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

getType
GType getType()
getItem
void* getItem(uint position)

Get the item at @position. If @position is greater than the number of items in @list, %NULL is returned.

getItemType
GType getItemType()

Gets the type of the items in @list. All items returned from g_list_model_get_type() are of that type or a subtype, or are an implementation of that interface.

getNItems
uint getNItems()

Gets the number of items in @list.

getObject
ObjectG getObject(uint position)

Get the item at @position. If @position is greater than the number of items in @list, %NULL is returned.

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

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

addOnItemsChanged
gulong addOnItemsChanged(void delegate(uint, uint, uint, ListModelIF) dlg, ConnectFlags connectFlags)

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.

From BuildableIF

getBuildableStruct
GtkBuildable* getBuildableStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

getType
GType getType()
getBuildableId
string getBuildableId()

Gets the ID of the @buildable object.

Meta