Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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 Label
, or by installing a key
binding using gtk_widget_class_add_binding()
, or by adding accelerators
to global actions using applicationSetAccelsForAction
.
But it is possible to create your own shortcut controller, and add shortcuts to it.
ShortcutController
implements ListModel
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: > > class='GtkButton' > child > class='GtkShortcutController' > name='scope'managed/property > child > class='GtkShortcut' > name='trigger'<Control>k/property > name='action'activate/property > /object > /child > /object > /child > /object
This example creates a ActivateAction
for triggering the activate
signal of the GtkButton. See shortcutActionParseString
for the syntax
for other kinds of ShortcutAction
. See shortcutTriggerParseString
to learn more about the syntax for triggers.
Synopsis
- newtype ShortcutController = ShortcutController (ManagedPtr ShortcutController)
- class (GObject o, IsDescendantOf ShortcutController o) => IsShortcutController o
- toShortcutController :: (MonadIO m, IsShortcutController o) => o -> m ShortcutController
- shortcutControllerAddShortcut :: (HasCallStack, MonadIO m, IsShortcutController a, IsShortcut b) => a -> b -> m ()
- shortcutControllerGetMnemonicsModifiers :: (HasCallStack, MonadIO m, IsShortcutController a) => a -> m [ModifierType]
- shortcutControllerGetScope :: (HasCallStack, MonadIO m, IsShortcutController a) => a -> m ShortcutScope
- shortcutControllerNew :: (HasCallStack, MonadIO m) => m ShortcutController
- shortcutControllerNewForModel :: (HasCallStack, MonadIO m, IsListModel a) => a -> m ShortcutController
- shortcutControllerRemoveShortcut :: (HasCallStack, MonadIO m, IsShortcutController a, IsShortcut b) => a -> b -> m ()
- shortcutControllerSetMnemonicsModifiers :: (HasCallStack, MonadIO m, IsShortcutController a) => a -> [ModifierType] -> m ()
- shortcutControllerSetScope :: (HasCallStack, MonadIO m, IsShortcutController a) => a -> ShortcutScope -> m ()
- constructShortcutControllerMnemonicModifiers :: (IsShortcutController o, MonadIO m) => [ModifierType] -> m (GValueConstruct o)
- getShortcutControllerMnemonicModifiers :: (MonadIO m, IsShortcutController o) => o -> m [ModifierType]
- setShortcutControllerMnemonicModifiers :: (MonadIO m, IsShortcutController o) => o -> [ModifierType] -> m ()
- constructShortcutControllerModel :: (IsShortcutController o, MonadIO m, IsListModel a) => a -> m (GValueConstruct o)
- constructShortcutControllerScope :: (IsShortcutController o, MonadIO m) => ShortcutScope -> m (GValueConstruct o)
- getShortcutControllerScope :: (MonadIO m, IsShortcutController o) => o -> m ShortcutScope
- setShortcutControllerScope :: (MonadIO m, IsShortcutController o) => o -> ShortcutScope -> m ()
Exported types
newtype ShortcutController Source #
Memory-managed wrapper type.
ShortcutController (ManagedPtr ShortcutController) |
Instances
class (GObject o, IsDescendantOf ShortcutController o) => IsShortcutController o Source #
Type class for types which can be safely cast to ShortcutController
, for instance with toShortcutController
.
Instances
(GObject o, IsDescendantOf ShortcutController o) => IsShortcutController o Source # | |
Defined in GI.Gtk.Objects.ShortcutController |
toShortcutController :: (MonadIO m, IsShortcutController o) => o -> m ShortcutController Source #
Cast to ShortcutController
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
addShortcut, bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, isFloating, itemsChanged, notify, notifyByPspec, ref, refSink, removeShortcut, reset, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getBuildableId, getCurrentEvent, getCurrentEventDevice, getCurrentEventState, getCurrentEventTime, getData, getItem, getItemType, getMnemonicsModifiers, getNItems, getName, getPropagationLimit, getPropagationPhase, getProperty, getQdata, getScope, getWidget.
Setters
setData, setDataFull, setMnemonicsModifiers, setName, setPropagationLimit, setPropagationPhase, setProperty, setScope.
addShortcut
shortcutControllerAddShortcut Source #
:: (HasCallStack, MonadIO m, IsShortcutController a, IsShortcut b) | |
=> a |
|
-> b |
|
-> m () |
Adds shortcut
to the list of shortcuts handled by self
.
If this controller uses an external shortcut list, this function does nothing.
getMnemonicsModifiers
shortcutControllerGetMnemonicsModifiers Source #
:: (HasCallStack, MonadIO m, IsShortcutController a) | |
=> a |
|
-> m [ModifierType] | Returns: the controller's mnemonics modifiers |
Gets the mnemonics modifiers for when this controller activates its shortcuts. See
shortcutControllerSetMnemonicsModifiers
for details.
getScope
shortcutControllerGetScope Source #
:: (HasCallStack, MonadIO m, IsShortcutController a) | |
=> a |
|
-> m ShortcutScope | Returns: the controller's scope |
Gets the scope for when this controller activates its shortcuts. See
shortcutControllerSetScope
for details.
new
shortcutControllerNew Source #
:: (HasCallStack, MonadIO m) | |
=> m ShortcutController | Returns: a newly created shortcut controller |
Creates a new shortcut controller.
newForModel
shortcutControllerNewForModel Source #
:: (HasCallStack, MonadIO m, IsListModel a) | |
=> a |
|
-> m ShortcutController | Returns: a newly created shortcut controller |
Creates a new shortcut controller that takes its shortcuts from the given list model.
A controller created by this function does not let you add or remove individual shortcuts using the shortcut controller api, but you can change the contents of the model.
removeShortcut
shortcutControllerRemoveShortcut Source #
:: (HasCallStack, MonadIO m, IsShortcutController a, IsShortcut b) | |
=> a |
|
-> b |
|
-> m () |
Removes shortcut
from the list of shortcuts handled by self
.
If shortcut
had not been added to controller
or this controller
uses an external shortcut list, this function does nothing.
setMnemonicsModifiers
shortcutControllerSetMnemonicsModifiers Source #
:: (HasCallStack, MonadIO m, IsShortcutController a) | |
=> a |
|
-> [ModifierType] |
|
-> m () |
Sets the controller to have the given mnemonicsModifiers
.
The mnemonics modifiers determines which modifiers need to be pressed to allow activation of shortcuts with mnemonics triggers.
GTK normally uses the Alt modifier for mnemonics, except in GtkPopoverMenus
,
where mnemonics can be triggered without any modifiers. It should be very
rarely necessary to change this, and doing so is likely to interfere with
other shortcuts.
This value is only relevant for local shortcut controllers. Global and managed shortcut controllers will have their shortcuts activated from other places which have their own modifiers for activating mnemonics.
setScope
shortcutControllerSetScope Source #
:: (HasCallStack, MonadIO m, IsShortcutController a) | |
=> a |
|
-> ShortcutScope |
|
-> m () |
Sets the controller to have the given scope
.
The scope allows shortcuts to be activated outside of the normal event propagation. In particular, it allows installing global keyboard shortcuts that can be activated even when a widget does not have focus.
With ShortcutScopeLocal
, shortcuts will only be activated
when the widget has focus.
Properties
mnemonicModifiers
The modifiers that need to be pressed to allow mnemonics activation.
constructShortcutControllerMnemonicModifiers :: (IsShortcutController o, MonadIO m) => [ModifierType] -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “mnemonic-modifiers
” property. This is rarely needed directly, but it is used by new
.
getShortcutControllerMnemonicModifiers :: (MonadIO m, IsShortcutController o) => o -> m [ModifierType] Source #
Get the value of the “mnemonic-modifiers
” property.
When overloading is enabled, this is equivalent to
get
shortcutController #mnemonicModifiers
setShortcutControllerMnemonicModifiers :: (MonadIO m, IsShortcutController o) => o -> [ModifierType] -> m () Source #
Set the value of the “mnemonic-modifiers
” property.
When overloading is enabled, this is equivalent to
set
shortcutController [ #mnemonicModifiers:=
value ]
model
A list model to take shortcuts from
constructShortcutControllerModel :: (IsShortcutController o, MonadIO m, IsListModel a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “model
” property. This is rarely needed directly, but it is used by new
.
scope
What scope the shortcuts will be handled in.
constructShortcutControllerScope :: (IsShortcutController o, MonadIO m) => ShortcutScope -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “scope
” property. This is rarely needed directly, but it is used by new
.
getShortcutControllerScope :: (MonadIO m, IsShortcutController o) => o -> m ShortcutScope Source #
Get the value of the “scope
” property.
When overloading is enabled, this is equivalent to
get
shortcutController #scope
setShortcutControllerScope :: (MonadIO m, IsShortcutController o) => o -> ShortcutScope -> m () Source #
Set the value of the “scope
” property.
When overloading is enabled, this is equivalent to
set
shortcutController [ #scope:=
value ]