c - clutter stage in gtk can't not handle stage mouse press event -
i have tried use clutter-gtk. wrote small piece of code create gtk window clutter stage in it. try mouse button press event on stage there nothing.
here code:
#include <clutter/clutter.h> #include <clutter-gtk/clutter-gtk.h> #include <glib.h> #include <stdlib.h> #include <stdio.h> /*gcc 3_clutter_app_clickable_text_in_gtk.c -o 3_clutter_app_clickable_text_in_gtk `pkg-config clutter-1.0 clutter-gtk-1.0 glib --cflags --libs`*/ /*mouse clic handler*/ void on_stage_button_press( clutterstage *stage, clutterevent *event, gpointer data) { printf("ok\n"); } int main(int argc, char *argv[]) { if (gtk_clutter_init(&argc, &argv) != clutter_init_success) return exit_failure; /*create window*/ gtkwidget *window = gtk_window_new (gtk_window_toplevel); gtk_window_set_default_size (gtk_window (window), 640, 480); /*destroy window close all*/ g_signal_connect(window, "destroy", g_callback(gtk_main_quit), null); /*vertical box, 0 spacing*/ gtkwidget * box = gtk_box_new(gtk_orientation_vertical,0); /*add box in window*/ gtk_container_add(gtk_container(window), box); /*create cutter widget*/ gtkwidget *clutter_widget = gtk_clutter_embed_new (); gtk_widget_set_size_request (clutter_widget, 200, 200); clutteractor *stage = gtk_clutter_embed_get_stage (gtk_clutter_embed(clutter_widget)); clutter_stage_set_use_alpha(clutter_stage(stage), true); cluttercolor stage_color ; gstring * bg_color = g_string_new("#555753ff"); clutter_color_from_string(&stage_color,bg_color->str); clutter_actor_set_background_color(stage, &stage_color); /*add cutter widget in box expand , fill true , spacing 0*/ gtk_box_pack_start (gtk_box (box), clutter_widget, true, true, 0); /*create line text*/ cluttercolor text_color; gstring * fg_color = g_string_new("#00000055"); clutter_color_from_string(&text_color, fg_color->str); clutteractor *some_text = clutter_text_new_full("sans 24", "hello, world", &text_color); clutter_actor_set_size(some_text, 256, 128); clutter_actor_set_position(some_text, 128, 128); clutter_actor_add_child(clutter_actor(stage), some_text); clutter_text_set_editable(clutter_text(some_text), true); /*define clic event*/ g_signal_connect(stage, "button-press-event", g_callback(on_stage_button_press), null); /* show window , widgets: */ gtk_widget_show_all (gtk_widget (window)); /* start main loop, can respond events: */ gtk_main (); return exit_success; }
nothing happens when click on stage. have made tests , can handle click event on main windows, on clutter_widget not directly on clutter stage.
this code modified 1 http://www.openismus.com/documents/clutter_tutorial/0.9/docs/tutorial/html/sec-stage-widget.html. in 1 author connect signal directly on stage example clutter 0.9 , don't compile anymore clutter v > 1.0.
any ideas on doing wrong?
edit
i have made test "key-press-event" handled. problem seems come events mask of stage.
does know how change event mask of stage in order force stage react on mouse events?
i close question because :
- clutter-gtk proof of concept
- clutter-gtk not used in future
see https://mail.gnome.org/archives/clutter-list/2013-february/msg00059.html
so don't want loose more time this.
for information,the same example using juste clutter works expected.
Comments
Post a Comment