hi
the GtkButton widget is handling the event and is returning TRUE,
thats why the event is not getting propagated to parents .
button-press-event is RUN-LAST so first your handler is called which returns
FALSE,
than default handler from GtkButton is called which returns true.
Thats why if you connect using g_signal_connect_after than none of your
handler will get called
See gtk_button_button_press handler in gtkbutton.c
bye
varun
2008/3/31 vronskij <[EMAIL PROTECTED]>:
> Hi,
>
> I have a small code example, It should demonstrate the event propagation
> in GTK+.
>
> I have three widgets. A button, fixed container and a window. I have three
>
> callbacks. After I click on the button, I expect a message from all these
> three widgets. First from the button, then from fixed container and from the
> window.
> I must be missing something, cause it is not working. I am getting message
> only from the button widget.
>
> How should I modify the example, so that the code works?
> Thanks for your suggestions.
>
> jan bodnar
>
> #include <gtk/gtk.h>
>
> static gboolean button_reached(GtkWidget *widget, GdkEvent *event,
> gpointer data)
> {
> g_print("button widget reached");
>
> return FALSE;
> }
>
>
> static gboolean fixed_reached(GtkWidget *widget, GdkEvent *event,
> gpointer data)
> {
> g_print("fixed container reached");
>
> return FALSE;
> }
>
>
> static gboolean window_reached(GtkWidget *widget, gpointer data)
> {
> g_print("window widget reached");
>
> return FALSE;
> }
>
> int main( int argc, char *argv[])
> {
>
> GtkWidget *window;
> GtkWidget *fixed;
> GtkWidget *button;
>
> gtk_init(&argc, &argv);
>
> window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
> gtk_window_set_default_size(GTK_WINDOW(window), 230, 150);
> gtk_window_set_title(GTK_WINDOW(window), "Simple");
> gtk_widget_add_events(window, GDK_BUTTON_PRESS_MASK);
>
> fixed = gtk_fixed_new();
> gtk_widget_add_events(fixed, GDK_BUTTON_PRESS_MASK);
>
> button = gtk_button_new_with_label("Button");
> gtk_fixed_put(GTK_FIXED(fixed), button, 50, 50);
> gtk_container_add(GTK_CONTAINER(window), fixed);
>
> g_signal_connect(G_OBJECT(button), "button-press-event",
> G_CALLBACK(button_reached), NULL);
>
> g_signal_connect(G_OBJECT(fixed), "button-press-event",
> G_CALLBACK(fixed_reached), NULL);
>
> g_signal_connect(G_OBJECT(window), "button-press-event",
> G_CALLBACK(window_reached), NULL);
>
> g_signal_connect_swapped(G_OBJECT(window), "destroy",
> G_CALLBACK(gtk_main_quit), G_OBJECT(window));
>
> gtk_widget_show_all(window);
>
> gtk_main();
>
> return 0;
> }
>
>
>
> _______________________________________________
> gtk-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
>
_______________________________________________
gtk-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-list