Action for clickable actors
<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)
{
case CLUTTER_LONG_PRESS_QUERY:
/* return TRUE if the actor should support long press
* gestures, and FALSE otherwise; this state will be
* emitted on button presses
*/
return TRUE;
case CLUTTER_LONG_PRESS_ACTIVATE:
/* this state is emitted if the minimum duration has
* been reached without the gesture being cancelled.
* the return value is not used
*/
return TRUE;
case CLUTTER_LONG_PRESS_CANCEL:
/* this state is emitted if the long press was cancelled;
* for instance, the pointer went outside the actor or the
* allowed threshold, or the button was released before
* the minimum duration was reached. the return value is
* not used
*/
return FALSE;
}
}
<clutter-click-action> is available since Clutter 1.4
<clutter-action>)Creates a new
<clutter-click-action>instance
- ret
- the newly created
<clutter-click-action>Since 1.4
<clutter-click-action>) ⇒ (ret unsigned-int)Retrieves the button that was pressed.
- action
- a
<clutter-click-action>- ret
- the button value
Since 1.4
<clutter-click-action>) ⇒ (ret <clutter-modifier-type>)Retrieves the modifier state of the click action.
- action
- a
<clutter-click-action>- ret
- the modifier state parameter, or 0
Since 1.6
<clutter-click-action>) ⇒ (press_x float) (press_y float)Retrieves the screen coordinates of the button press.
- action
- a
<clutter-click-action>- press-x
- return location for the X coordinate, or ‘
#f’.- press-y
- return location for the Y coordinate, or ‘
#f’.Since 1.8
<clutter-click-action>)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.
- action
- a
<clutter-click-action>Since 1.4