mirror of
https://github.com/brl/mutter.git
synced 2025-06-13 16:59:30 +00:00
build
clutter
doc
common
cookbook
examples
Makefile.am
animations-complex-overlapping.json
animations-complex.c
animations-complex.json
animations-moving-animator.c
animations-moving-implicit.c
animations-moving-state.c
animations-reuse-animation.json
animations-reuse-ui.json
animations-reuse.c
animations-rotating.c
events-buttons-click.c
events-buttons-lasso.c
events-buttons.c
events-mouse-scroll.c
events-pointer-motion-crossing.c
events-pointer-motion-scribbler.c
events-pointer-motion-stacked.c
events-pointer-motion.c
layouts-bind-constraint-allocation.c
layouts-bind-constraint-overlay.c
layouts-bind-constraint-stage.c
layouts-stacking-diff-sized-actors.c
layouts-stacking.c
script-signals.c
script-signals.json
script-ui.c
script-ui.json
smiley.png
text-shadow.c
textures-crossfade-cogl.c
textures-crossfade-slideshow.c
textures-crossfade.c
textures-reflection.c
textures-split-go.c
textures-sub-texture.c
images
videos
Makefile.am
actors.xml
animations.xml
clutter-cookbook.xml.in
events.xml
introduction.xml
layouts.xml
recipe-template.xml
script.xml
text.xml
textures.xml
version.xml.in
manual
reference
CODING_STYLE
HACKING
HACKING.backends
Makefile.am
RELEASING
clutter-actor-invariants.txt
po
tests
.gitignore
AUTHORS
COPYING
ChangeLog.pre-git-import
Makefile.am
NEWS
README
autogen.sh
clutter.doap
configure.ac

Added an example showing how to examine the content of a ClutterButtonEvent in a signal handler.
108 lines
2.9 KiB
C
108 lines
2.9 KiB
C
#include <stdlib.h>
|
|
#include <clutter/clutter.h>
|
|
|
|
static const ClutterColor stage_color = { 0x33, 0x33, 0x55, 0xff };
|
|
static const ClutterColor red_color = { 0xff, 0x00, 0x00, 0xff };
|
|
static const ClutterColor green_color = { 0x00, 0xff, 0x00, 0xff };
|
|
|
|
static gboolean
|
|
button_event_cb (ClutterActor *actor,
|
|
ClutterEvent *event,
|
|
gpointer user_data)
|
|
{
|
|
gfloat x, y;
|
|
gchar *event_type;
|
|
guint button_pressed;
|
|
ClutterModifierType state;
|
|
gchar *ctrl_pressed;
|
|
guint32 click_count;
|
|
|
|
/* where the pointer was when the button event occurred */
|
|
clutter_event_get_coords (event, &x, &y);
|
|
|
|
/* check whether it was a press or release event */
|
|
event_type = "released";
|
|
if (clutter_event_type (event) == CLUTTER_BUTTON_PRESS)
|
|
event_type = "pressed";
|
|
|
|
/* which button triggered the event */
|
|
button_pressed = clutter_event_get_button (event);
|
|
|
|
/* keys down when the button was pressed */
|
|
state = clutter_event_get_state (event);
|
|
|
|
ctrl_pressed = "ctrl not pressed";
|
|
if (state & CLUTTER_CONTROL_MASK)
|
|
ctrl_pressed = "ctrl pressed";
|
|
|
|
/* click count */
|
|
click_count = clutter_event_get_click_count (event);
|
|
|
|
g_debug ("button %d %s at %.0f,%.0f; %s; click count %d",
|
|
button_pressed,
|
|
event_type,
|
|
x,
|
|
y,
|
|
ctrl_pressed,
|
|
click_count);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
int
|
|
main (int argc,
|
|
char *argv[])
|
|
{
|
|
ClutterActor *stage;
|
|
ClutterActor *red;
|
|
ClutterActor *green;
|
|
|
|
clutter_init (&argc, &argv);
|
|
|
|
stage = clutter_stage_get_default ();
|
|
clutter_actor_set_size (stage, 400, 400);
|
|
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
|
|
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
|
|
|
|
red = clutter_rectangle_new_with_color (&red_color);
|
|
clutter_actor_set_size (red, 100, 100);
|
|
clutter_actor_set_position (red, 50, 150);
|
|
clutter_actor_set_reactive (red, TRUE);
|
|
|
|
green = clutter_rectangle_new_with_color (&green_color);
|
|
clutter_actor_set_size (green, 100, 100);
|
|
clutter_actor_set_position (green, 250, 150);
|
|
clutter_actor_set_reactive (green, TRUE);
|
|
|
|
g_signal_connect (red,
|
|
"button-press-event",
|
|
G_CALLBACK (button_event_cb),
|
|
NULL);
|
|
|
|
g_signal_connect (red,
|
|
"button-release-event",
|
|
G_CALLBACK (button_event_cb),
|
|
NULL);
|
|
|
|
g_signal_connect (green,
|
|
"button-press-event",
|
|
G_CALLBACK (button_event_cb),
|
|
NULL);
|
|
|
|
g_signal_connect (green,
|
|
"button-release-event",
|
|
G_CALLBACK (button_event_cb),
|
|
NULL);
|
|
|
|
clutter_container_add (CLUTTER_CONTAINER (stage),
|
|
red,
|
|
green,
|
|
NULL);
|
|
|
|
clutter_actor_show (stage);
|
|
|
|
clutter_main ();
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|