Re: Signal question



Jiang XU writes:
I have a gtk_entry in a gtk_window.
If I do not want gtk_entry receive "button_press_event" signal,  what
should I do?

According the online Tutorial, if the event signal not being handled by
the gtk_entry, it will go to the widget's parent which is gtk_window.
That is what I want, but I don't know how to disconnect the
"button_press_event" from gtk_entry.

What works is to connect the signal to

        gint foo (GtkObject *object)
        {
           gtk_signal_emit_stop_by_name (object, "button_press_event");
           return FALSE;
        }

but this looks quite ugly.
 
You can also also do this:

        gtk_signal_connect_after (GTK_OBJECT (entry), "button_press_event",
                                  GTK_SIGNAL_FUNC (gtk_false), NULL);

to let the event be handled by the entry *and* go to the window.

BTW, I looked into gtkentry.c and found that gtk_entry_button_press
always returns FALSE, which in my program causes the (grand)-parent
widget to be focussed when I click on the entry. I tried

        gtk_signal_connect_after (GTK_OBJECT (entry), "button_press_event",
                                  GTK_SIGNAL_FUNC (gtk_true), NULL);

and it works. I'm using a quite outdated version of Gtk+ (1.2.1), is
this a bug, or intended, or already fixed, or what else ...?

Sebastian




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]