diff options
author | Emmanuele Bassi <ebassi@linux.intel.com> | 2010-08-09 15:05:06 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@linux.intel.com> | 2010-08-09 15:05:06 +0100 |
commit | 2eb1e5322b6a6036d354c9eaeeeb1ecc14fbf269 (patch) | |
tree | 6ae32a5af4609a87cb655c12da4511686f662c87 /examples | |
parent | d8aebdd0aab894ba15a9503040a84ccb28ad3f3c (diff) | |
download | clutter-gtk-2eb1e5322b6a6036d354c9eaeeeb1ecc14fbf269.tar.gz |
embed: Forward Key events
Apparently, the GDK filter function we use with GtkClutterEmbed is not
receiving any key event. In order to make them work, we need to fall
back to the event forwarding we used prior to 0.90.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/gtk-clutter-events.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/examples/gtk-clutter-events.c b/examples/gtk-clutter-events.c index 4397384..f81af27 100644 --- a/examples/gtk-clutter-events.c +++ b/examples/gtk-clutter-events.c @@ -115,6 +115,20 @@ on_stage_capture (ClutterActor *stage, } break; + case CLUTTER_KEY_PRESS: + { + gchar buf[8]; + gint n_chars; + + n_chars = g_unichar_to_utf8 (clutter_event_get_key_unicode (event), buf); + buf[n_chars] = '\0'; + g_print ("the stage got a key press: '%s' (symbol: %d, unicode: 0x%x)\n", + buf, + clutter_event_get_key_symbol (event), + clutter_event_get_key_unicode (event)); + } + break; + default: break; } @@ -143,7 +157,7 @@ main (gint argc, gchar **argv) ClutterColor stage_color = {255, 255, 255, 255}; ClutterColor text_color = {0, 0, 0, 255}; - if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) + if (gtk_clutter_init_with_args (&argc, &argv, "- Event test", NULL, NULL, NULL) != CLUTTER_INIT_SUCCESS) g_error ("Unable to initialize GtkClutter"); /* Create the inital gtk window and widgets, just like normal */ @@ -172,6 +186,7 @@ main (gint argc, gchar **argv) create_colors (app, &stage_color, &text_color); widget = gtk_clutter_embed_new (); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); + gtk_widget_grab_focus (widget); app->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (widget)); clutter_stage_set_color (CLUTTER_STAGE (app->stage), &stage_color); gtk_widget_set_size_request (widget, 640, 480); |