Next: , Previous: ClutterDeviceManager, Up: Top


30 ClutterDragAction

Action enabling dragging on actors

30.1 Overview

<clutter-drag-action> is a sub-class of <clutter-action> that implements all the necessary logic for dragging actors.

The simplest usage of <clutter-drag-action> consists in adding it to a <clutter-actor> and setting it as reactive; for instance, the following code:

     
       clutter_actor_add_action (actor, clutter_drag_action_new ());
       clutter_actor_set_reactive (actor, TRUE);

will automatically result in the actor moving to follow the pointer whenever the pointer's button is pressed over the actor and moved across the stage.

The <clutter-drag-action> will signal the begin and the end of a dragging through the <"drag-begin"> and <"drag-end"> signals, respectively. Each pointer motion during a drag will also result in the <"drag-motion"> signal to be emitted.

It is also possible to set another <clutter-actor> as the dragged actor by calling clutter-drag-action-set-drag-handle from within a handle of the <"drag-begin"> signal. The drag handle must be parented and exist between the emission of <"drag-begin"> and <"drag-end">.

     

The example program above allows dragging the rectangle around the stage using a <clutter-drag-action>. When pressing the "Shift") key the actor that is going to be dragged is a separate rectangle, and when the drag ends, the original rectangle will be animated to the final coordinates.

<clutter-drag-action> is available since Clutter 1.4

30.2 Usage

— Function: clutter-drag-action-new ⇒  (ret <clutter-action>)

Creates a new <clutter-drag-action> instance

ret
the newly created <clutter-drag-action>

Since 1.4

— Function: clutter-drag-action-set-drag-handle (self <clutter-drag-action>) (handle <clutter-actor>)
— Method: set-drag-handle

Sets the actor to be used as the drag handle.

action
a <clutter-drag-action>
handle
a <clutter-actor>, or ‘#f’ to unset.

Since 1.4

— Function: clutter-drag-action-get-drag-handle (self <clutter-drag-action>) ⇒  (ret <clutter-actor>)
— Method: get-drag-handle

Retrieves the drag handle set by clutter-drag-action-set-drag-handle

action
a <clutter-drag-action>
ret
a <clutter-actor>, used as the drag handle, or ‘#f’ if none was set.

Since 1.4

— Function: clutter-drag-action-set-drag-axis (self <clutter-drag-action>) (axis <clutter-drag-axis>)
— Method: set-drag-axis

Restricts the dragging action to a specific axis

action
a <clutter-drag-action>
axis
the axis to constraint the dragging to

Since 1.4

— Function: clutter-drag-action-get-drag-axis (self <clutter-drag-action>) ⇒  (ret <clutter-drag-axis>)
— Method: get-drag-axis

Retrieves the axis constraint set by clutter-drag-action-set-drag-axis

action
a <clutter-drag-action>
ret
the axis constraint

Since 1.4