---
name: "Gtk2::BindingSet"
section: "3pm"
platform: "linux"
package: "libgtk2-perl-doc"
version: "2:1.24992-1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/Gtk2::BindingSet"
---

# Gtk2::BindingSet(3pm)

wrapper for GtkBindingSet

## NAME

Gtk2::BindingSet - wrapper for GtkBindingSet

## DESCRIPTION

A `"Gtk2::BindingSet"` is basically a mapping from keyval+modifiers to a named action signal to invoke and with argument values for the signal.  Bindings are normally run by the `"Gtk2::Widget"` default `"key-press-event"` handler, but can also be activated explicitly.

Binding sets can be populated from program code with `"entry_add_signal"`, or created from an RC file or string (see Gtk2::Rc).  If you use the RC note it doesn't parse and create anything until there's someone interested in the result, such as `"Gtk2::Settings"` for widgets.	This means binding sets in RC files or strings don't exist for `"Gtk2::BindingSet->find"` to retrieve until at least one widget has been created (or similar).

Currently there's no Perl-level access to the contents of a BindingSet, except for `"set_name"`.

## HIERARCHY

```
  Glib::Boxed
  +----Gtk2::BindingSet
```

## METHODS

### GtkBindingSet = Gtk2::BindingSet-\>new ($set\_name)

- •

  `$set_name` (string)

### boolean = $binding\_set-\>activate ($keyval, $modifiers, $object)

- •

  `$keyval` (integer)

- •

  `$modifiers` (Gtk2::Gdk::ModifierType)

- •

  `$object` (Gtk2::Object)

### $binding\_set-\>add\_path ($path\_type, $path\_pattern, $priority)

- •

  `$path_type` (Gtk2::PathType)

- •

  `$path_pattern` (string)

- •

  `$priority` (integer)

The following constants are defined for standard priority levels,

```
    Gtk2::GTK_PATH_PRIO_LOWEST
    Gtk2::GTK_PATH_PRIO_GTK
    Gtk2::GTK_PATH_PRIO_APPLICATION
    Gtk2::GTK_PATH_PRIO_THEME
    Gtk2::GTK_PATH_PRIO_RC
    Gtk2::GTK_PATH_PRIO_HIGHEST
```

LOWEST, which is 0, and HIGHEST, which is 15, are the limits of the allowed priorities.  The standard values are from the `"Gtk2::PathPriorityType"` enum, but the parameter here is an integer, not an enum string, so you can give a value for instance a little above or below the pre-defined levels.

### bindingset or undef = Gtk2::BindingSet-\>by\_class ($name)

- •

  `$name` (string)

### $binding\_set-\>entry\_add\_signal ($keyval, $modifiers, $signal\_name)

### $binding\_set-\>entry\_add\_signal ($keyval, $modifiers, $signal\_name, $type,$value, ...)

- •

  `$keyval` (integer)

- •

  `$modifiers` (Gtk2::Gdk::ModifierType)

- •

  `$signal_name` (string)

- •

  `$value` (scalar)

- •

  `$type` (string)

Add an entry to `$binding_set`.  `$keyval` and `$modifier` are setup as a binding for `$signal_name` and with signal parameters given by `$value` arguments.  Each value is preceded by a type (a string), which must be one of

```
    Glib::Long
    Glib::Double
    Glib::String
    an enum type, ie. subtype of Glib::Enum
    Glib::Flags, or a flags subtype
```

For example,

```
    $binding_set->entry_add_signal
        (Gtk2->keyval_from_name('Return'),
         [ 'control-mask' ],   # modifiers
         'some-signal-name',
         'Glib::Double', 1.5,
         'Glib::String,  'hello');
```

A parameter holds one of the three types Long, Double or String.  When invoked they're coerced to the parameter types expected by the target object or widget.  Use Glib::Long for any integer argument, including chars and unichars by ordinal value.  Use Glib::Double for both single and double precision floats.

Flags and enums are held as Longs in the BindingSet.  You can pass an enum type and string and `"entry_with_signal"` will lookup and store accordingly.  For example

```
    $binding_set->entry_add_signal
        (Gtk2->keyval_from_name('Escape), [],
         'set-direction',
         'Gtk2::Orientation', 'vertical');
```

Likewise flags from an arrayref,

```
    $binding_set->entry_add_signal
        (Gtk2->keyval_from_name('d'), [],
         'initiate-drag',
         'Gtk2::Gdk::DragAction', ['move,'ask']);
```

If you've got a Glib::Flags object, rather than just an arrayref, then you can just give Glib::Flags as the type and the value is taken from the object.  For example,

```
    my $flags = Gtk2::DebugFlag->new (['tree', 'updates']);
    $binding_set->entry_add_signal
        (Gtk2->keyval_from_name('x'), ['control-mask'],
         'change-debug',
         'Glib::Flags', $flags);
```

### $binding\_set-\>entry\_remove ($keyval, $modifiers)

- •

  `$keyval` (integer)

- •

  `$modifiers` (Gtk2::Gdk::ModifierType)

### $binding\_set-\>entry\_skip ($keyval, $modifiers)

- •

  `$keyval` (integer)

- •

  `$modifiers` (Gtk2::Gdk::ModifierType)

Since: gtk+ 2.12

### bindingset or undef = Gtk2::BindingSet-\>find ($name)

- •

  `$name` (string)

### string = $binding\_set-\>set\_name

Return the name of `$binding_set`.

## ENUMS AND FLAGS

### flags Gtk2::Gdk::ModifierType

- •

  'shift-mask' / 'GDK\_SHIFT\_MASK'

- •

  'lock-mask' / 'GDK\_LOCK\_MASK'

- •

  'control-mask' / 'GDK\_CONTROL\_MASK'

- •

  'mod1-mask' / 'GDK\_MOD1\_MASK'

- •

  'mod2-mask' / 'GDK\_MOD2\_MASK'

- •

  'mod3-mask' / 'GDK\_MOD3\_MASK'

- •

  'mod4-mask' / 'GDK\_MOD4\_MASK'

- •

  'mod5-mask' / 'GDK\_MOD5\_MASK'

- •

  'button1-mask' / 'GDK\_BUTTON1\_MASK'

- •

  'button2-mask' / 'GDK\_BUTTON2\_MASK'

- •

  'button3-mask' / 'GDK\_BUTTON3\_MASK'

- •

  'button4-mask' / 'GDK\_BUTTON4\_MASK'

- •

  'button5-mask' / 'GDK\_BUTTON5\_MASK'

- •

  'super-mask' / 'GDK\_SUPER\_MASK'

- •

  'hyper-mask' / 'GDK\_HYPER\_MASK'

- •

  'meta-mask' / 'GDK\_META\_MASK'

- •

  'release-mask' / 'GDK\_RELEASE\_MASK'

- •

  'modifier-mask' / 'GDK\_MODIFIER\_MASK'

### enum Gtk2::PathType

- •

  'widget' / 'GTK\_PATH\_WIDGET'

- •

  'widget-class' / 'GTK\_PATH\_WIDGET\_CLASS'

- •

  'class' / 'GTK\_PATH\_CLASS'

## SEE ALSO

Gtk2, Glib::Boxed

## COPYRIGHT

Copyright (C) 2003-2011 by the gtk2-perl team.

This software is licensed under the LGPL.  See Gtk2 for a full notice.
