### Class

# Clutter BindingPool

#### Description [src]

    final class Clutter.BindingPool : GObject.Object
    {
      /* No available fields */
    }

Pool for key bindings

`ClutterBindingPool` is a data structure holding a set of key bindings. Each key binding associates a key symbol (eventually with modifiers) to an action. A callback function is associated to each action.

For a given key symbol and modifier mask combination there can be only one action; for each action there can be only one callback. There can be multiple actions with the same name, and the same callback can be used to handle multiple key bindings.

Actors requiring key bindings should create a new `ClutterBindingPool` inside their class initialization function and then install actions like this:

    static void
    foo_class_init (FooClass *klass)
    {
      ClutterBindingPool *binding_pool;

      binding_pool = clutter_binding_pool_get_for_class (klass);

      clutter_binding_pool_install_action (binding_pool, "move-up",
                                           CLUTTER_Up, 0,
                                           G_CALLBACK (foo_action_move_up),
                                           NULL, NULL);
      clutter_binding_pool_install_action (binding_pool, "move-up",
                                           CLUTTER_KP_Up, 0,
                                           G_CALLBACK (foo_action_move_up),
                                           NULL, NULL);
    }

The callback has a signature of:

       gboolean (* callback) (GObject             *instance,
                              const gchar         *action_name,
                              guint                key_val,
                              ClutterModifierType  modifiers,
                              gpointer             user_data);

The actor should then override the `ClutterActor::key-press-event` and use `clutter_binding_pool_activate()` to match a `ClutterEvent` key event structure to one of the actions:

      ClutterBindingPool *pool;

      // retrieve the binding pool for the type of the actor
      pool = clutter_binding_pool_find (G_OBJECT_TYPE_NAME (actor));

      // activate any callback matching the key symbol and modifiers
      // mask of the key event. the returned value can be directly
      // used to signal that the actor has handled the event.
      return clutter_binding_pool_activate (pool,
                                            key_event->keyval,
                                            key_event->modifier_state,
                                            G_OBJECT (actor));

The `clutter_binding_pool_activate()` function will return `FALSE` if no action for the given key binding was found, if the action was blocked (using `clutter_binding_pool_block_action()`) or if the key binding handler returned `FALSE`.

#### Ancestors

- GObject

#### Constructors

###### clutter_binding_pool_new

Creates a new `ClutterBindingPool` that can be used to store key bindings for an actor. The `name` must be a unique identifier for the binding pool, so that `clutter_binding_pool_find()` will be able to return the correct binding pool.

#### Functions

###### clutter_binding_pool_find

Finds the `ClutterBindingPool` with `name`.

###### clutter_binding_pool_get_for_class

Retrieves the `ClutterBindingPool` for the given `GObject` class and, eventually, creates it. This function is a wrapper around `clutter_binding_pool_new()` and uses the class type name as the unique name for the binding pool.

#### Instance methods

###### clutter_binding_pool_activate

Activates the callback associated to the action that is bound to the `key_val` and `modifiers` pair.

###### clutter_binding_pool_block_action

Blocks all the actions with name `action_name` inside `pool`.

###### clutter_binding_pool_find_action

Retrieves the name of the action matching the given key symbol and modifiers bitmask.

###### clutter_binding_pool_install_action

Installs a new action inside a `ClutterBindingPool`. The action is bound to `key_val` and `modifiers`.

###### clutter_binding_pool_install_closure

A `GClosure` variant of `clutter_binding_pool_install_action()`.

###### clutter_binding_pool_override_action

Allows overriding the action for `key_val` and `modifiers` inside a `ClutterBindingPool`. See `clutter_binding_pool_install_action()`.

###### clutter_binding_pool_override_closure

A `GClosure` variant of `clutter_binding_pool_override_action()`.

###### clutter_binding_pool_remove_action

Removes the action matching the given `key_val`, `modifiers` pair, if any exists.

###### clutter_binding_pool_unblock_action

Unblockes all the actions with name `action_name` inside `pool`.

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

###### Clutter.BindingPool:name

The unique name of the `ClutterBindingPool`.

#### Signals

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct ClutterBindingPoolClass {
      GObjectClass parent_class;

    }

No description available.

###### Class members

`parent_class: GObjectClass`

  No description available.