Re: Stopping signals from being passed to parent (possible bug)
- From: Owen Taylor <owt1 cornell edu>
- To: "GTK List" <gtk-list redhat com>
- Subject: Re: Stopping signals from being passed to parent (possible bug)
- Date: 23 Mar 1998 11:32:45 -0500
"Damon Chaplin" <DAChaplin@email.msn.com> writes:
> Hi,
>
> Am I right in assuming that if you return TRUE from a signal handler
> then the signal will NOT be passed on to the widget's parent?
>
> That doesn't always seem to be the case.
>
> Below is a simple program with a hscrollbar in a window, both set
> up to pass 'button_press' events to the 'on_button_press' handler,
> which always returns TRUE.
>
> If you click on the scrollbar, both the scrollbar and the window
> get the event.
>
> (I've also had problems with entry & text - there may be others)
>
> Damon
The explaination for your observation is that all event signals
are of type GTK_RUN_LAST, which means that the default handler
runs _after_ your handler, so it's its return value that counts,
not yours.
Since the default handlers all return FALSE (Why? I don't know),
the events get propagated to the parents.
To get the behavior you expect, connect the the event with
gtk_signal_connect_after()
This will make sure your handler gets called after the default
handler, even for GTK_RUN_LAST.
(You could also make an explicit check:
if (event->window == widget->window)
...
in your event handler for the parent to filter out such propagated
events)
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]