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

GI.Gtk.Objects.ShortcutController

Description

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

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:

xml code

 <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 ActivateAction for triggering the activate signal of the GtkButton. See shortcutActionParseString for the syntax for other kinds of GtkShortcutAction. 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 GtkShortcut

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

-> m [ModifierType]

Returns: the controller's mnemonics modifiers

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

getScope

shortcutControllerGetScope Source #

Arguments

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

self: a GtkShortcutController

-> 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 GListModel 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 GtkShortcut

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

-> [ModifierType]

modifiers: the new mnemonics_modifiers to use

-> m () 

Sets the controller to use the given modifier for mnemonics.

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 GtkShortcutController

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

itemType

The type of items. See listModelGetItemType.

Since: 4.8

getShortcutControllerItemType :: (MonadIO m, IsShortcutController o) => o -> m GType Source #

Get the value of the “item-type” property. When overloading is enabled, this is equivalent to

get shortcutController #itemType

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.

nItems

The number of items. See listModelGetNItems.

Since: 4.8

getShortcutControllerNItems :: (MonadIO m, IsShortcutController o) => o -> m Word32 Source #

Get the value of the “n-items” property. When overloading is enabled, this is equivalent to

get shortcutController #nItems

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 ]