Next: , Previous: ClutterCairoTexture, Up: Top

20 ClutterClickAction

Action for clickable actors

20.1 Overview

<clutter-click-action> is a sub-class of <clutter-action> that implements the logic for clickable actors, by using the low level events of <clutter-actor>, such as <"button-press-event"> and <"button-release-event">, to synthesize the high level <"clicked"> signal.

To use <clutter-click-action> you just need to apply it to a <clutter-actor> using clutter-actor-add-action and connect to the <"clicked"> signal:

       ClutterAction *action = clutter_click_action_new ();
       clutter_actor_add_action (actor, action);
       g_signal_connect (action, "clicked", G_CALLBACK (on_clicked), NULL);

<clutter-click-action> also supports long press gestures: a long press is activated if the pointer remains pressed within a certain threshold (as defined by the <"long-press-threshold"> property) for a minimum amount of time (as the defined by the <"long-press-duration"> property). The <"long-press"> signal is emitted multiple times, using different <clutter-long-press-state> values; to handle long presses you should connect to the <"long-press"> signal and handle the different states:

       static gboolean
       on_long_press (ClutterClickAction    *action,
                      ClutterActor          *actor,
                      ClutterLongPressState  state)
         switch (state)
             /&#x002A; return TRUE if the actor should support long press
              &#x002A; gestures, and FALSE otherwise; this state will be
              &#x002A; emitted on button presses
             return TRUE;
             /&#x002A; this state is emitted if the minimum duration has
              &#x002A; been reached without the gesture being cancelled.
              &#x002A; the return value is not used
             return TRUE;
             /&#x002A; this state is emitted if the long press was cancelled;
              &#x002A; for instance, the pointer went outside the actor or the
              &#x002A; allowed threshold, or the button was released before
              &#x002A; the minimum duration was reached. the return value is
              &#x002A; not used
             return FALSE;

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

20.2 Usage

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

Creates a new <clutter-click-action> instance

the newly created <clutter-click-action>

Since 1.4

— Function: clutter-click-action-get-button (self <clutter-click-action>) ⇒  (ret unsigned-int)
— Method: get-button

Retrieves the button that was pressed.

a <clutter-click-action>
the button value

Since 1.4

— Function: clutter-click-action-get-state (self <clutter-click-action>) ⇒  (ret <clutter-modifier-type>)
— Method: get-state

Retrieves the modifier state of the click action.

a <clutter-click-action>
the modifier state parameter, or 0

Since 1.6

— Function: clutter-click-action-get-coords (self <clutter-click-action>) ⇒  (press_x float) (press_y float)
— Method: get-coords

Retrieves the screen coordinates of the button press.

a <clutter-click-action>
return location for the X coordinate, or ‘#f’.
return location for the Y coordinate, or ‘#f’.

Since 1.8

— Function: clutter-click-action-release (self <clutter-click-action>)
— Method: release

Emulates a release of the pointer button, which ungrabs the pointer and unsets the <"pressed"> state.

This function will also cancel the long press gesture if one was initiated.

This function is useful to break a grab, for instance after a certain amount of time has passed.

a <clutter-click-action>

Since 1.4