gi-gtk-4.0.4: Gtk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gtk.Objects.ShortcutController

Description

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

Exported types

newtype ShortcutController Source #

Memory-managed wrapper type.

Constructors

ShortcutController (ManagedPtr ShortcutController) 

Instances

Instances details
Eq ShortcutController Source # 
Instance details

Defined in GI.Gtk.Objects.ShortcutController

GObject ShortcutController Source # 
Instance details

Defined in GI.Gtk.Objects.ShortcutController

ManagedPtrNewtype ShortcutController Source # 
Instance details

Defined in GI.Gtk.Objects.ShortcutController

TypedObject ShortcutController Source # 
Instance details

Defined in GI.Gtk.Objects.ShortcutController

Methods

glibType :: IO GType

HasParentTypes ShortcutController Source # 
Instance details

Defined in GI.Gtk.Objects.ShortcutController

IsGValue (Maybe ShortcutController) Source #

Convert ShortcutController to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.ShortcutController

type ParentTypes ShortcutController Source # 
Instance details

Defined in GI.Gtk.Objects.ShortcutController

type ParentTypes ShortcutController = '[EventController, Object, ListModel, Buildable]

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

Instances details
(GObject o, IsDescendantOf ShortcutController o) => IsShortcutController o Source # 
Instance details

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

addShortcut

shortcutControllerAddShortcut Source #

Arguments

:: (HasCallStack, MonadIO m, IsShortcutController a, IsShortcut b) 
=> a

self: the controller

-> b

shortcut: a Shortcut

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

Arguments

:: (HasCallStack, MonadIO m, IsShortcutController a) 
=> a

self: a ShortcutController

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

Arguments

:: (HasCallStack, MonadIO m, IsShortcutController a) 
=> a

self: a ShortcutController

-> m ShortcutScope

Returns: the controller's scope

Gets the scope for when this controller activates its shortcuts. See shortcutControllerSetScope for details.

new

shortcutControllerNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m ShortcutController

Returns: a newly created shortcut controller

Creates a new shortcut controller.

newForModel

shortcutControllerNewForModel Source #

Arguments

:: (HasCallStack, MonadIO m, IsListModel a) 
=> a

model: a ListModel containing shortcuts

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

Arguments

:: (HasCallStack, MonadIO m, IsShortcutController a, IsShortcut b) 
=> a

self: the controller

-> b

shortcut: a Shortcut

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

Arguments

:: (HasCallStack, MonadIO m, IsShortcutController a) 
=> a

self: a ShortcutController

-> [ModifierType]

modifiers: the new mnemonics_modifiers to use

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

Arguments

:: (HasCallStack, MonadIO m, IsShortcutController a) 
=> a

self: a ShortcutController

-> ShortcutScope

scope: the new scope to use

-> 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 ]