gi-gtk4-4.0.12: Gtk 4.x bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Objects.ShortcutController

Contents

- Exported types
- Methods
  - addShortcut
  - getMnemonicsModifiers
  - getScope
  - new
  - newForModel
  - removeShortcut
  - setMnemonicsModifiers
  - setScope
- Properties
  - itemType
  - mnemonicModifiers
  - model
  - nItems
  - scope

Description

Manages keyboard shortcuts and their activation.

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 `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 `ListModel` for querying the shortcuts that have been added to it.

# GtkShortcutController as GtkBuildable

`GtkShortcutController`s can be created in `Builder` 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 `Button`. 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 ()
- getShortcutControllerItemType :: (MonadIO m, IsShortcutController o) => o -> m GType
- 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)
- getShortcutControllerNItems :: (MonadIO m, IsShortcutController o) => o -> m Word32
- 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.

Constructors

ShortcutController (ManagedPtr ShortcutController) |

#### Instances

Instances details

Eq ShortcutController Source # |
Instance details Defined in GI.Gtk.Objects.ShortcutController Methods (==) :: ShortcutController -> ShortcutController -> Bool Source # (/=) :: ShortcutController -> ShortcutController -> Bool Source #
GObject ShortcutController Source # |
Instance details Defined in GI.Gtk.Objects.ShortcutController
ManagedPtrNewtype ShortcutController Source # |
Instance details Defined in GI.Gtk.Objects.ShortcutController Methods toManagedPtr :: ShortcutController -> ManagedPtr ShortcutController Source #
TypedObject ShortcutController Source # |
Instance details Defined in GI.Gtk.Objects.ShortcutController Methods glibType :: IO GType Source #
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 Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe ShortcutController -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe ShortcutController) Source #
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

### Click to display all available methods, including inherited ones

Expand

#### 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, setStaticName.

## 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 `GtkPopoverMenu`s, 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 ]