Re: Bug in gtk 1.2?
- From: Owen Taylor <otaylor redhat com>
- To: Ketil Froyn <ketilf ifi uio no>
- Cc: gtk-list redhat com
- Subject: Re: Bug in gtk 1.2?
- Date: 04 Apr 1999 19:17:23 -0400
Ketil Froyn <ketilf@ifi.uio.no> writes:
> On 4 Apr 1999, Owen Taylor wrote:
>
> > Sounds like things are getting highly confused ... I don't
> > think this has anything thing with the gtk_main_iteration()
> > stuff.
>
> But it does. This program also makes the button over-sensitive, but it
> doesn't redirect events like my program did. I am compelled to believe
> that these bugs are somehow related, though.
[...]
> void callback(GtkWidget *widget, gpointer data)
> {
> g_print("Pressed\n");
> gtk_main_iteration();
> }
[...]
>
> gtk_signal_connect(GTK_OBJECT(button),"button_press_event",
> GTK_SIGNAL_FUNC(callback),NULL);
It's not too suprising that this is getting GTK+ into
a confused state.
What you program probably does is reverse the order of
the press and release events that the Button widget sees.
You callback handler intercepts the press event, then
dispatches the next event to the button (the release
event) then returns.
This results in messed up internal fields in the Button
widget and possibly a stuck grab. (What you were were
seeing with all events being directed to the button)
There is a good chance that you wanted to connect
to "clicked" instead of "button_press_event"
"button_press_event": raw event for user pressing the mouse button
"clicked": the user clicked on the button then released over it
If you did want to grab the raw event button, then you
have an obligation to hide that event from being processed
by the Button widget, like:
gboolean
callback(GtkWidget *widget, GtkEventButton *event, gpointer data)
{
g_print("Pressed\n");
/* Stop further processing of this signal emisssion */
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "button_press_event");
gtk_main_iteration();
return TRUE; /* I handled the event, don't propagate it */
}
[ Note the change in callback signature! *_event callbacksn must
look like this! ]
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]