Re: Having an event box pass unhandled events to its child



On Sun, 24 May 2009 09:24:19 +0300
Dov Grobgeld <dov grobgeld gmail com> wrote:
> In my last email, that unfortunately no one answered, I asked how to
> get right click to work on any widget.  Since I didn't find a
> solution to that I thought to do a work around by putting the widget
> I want to add right-click to into an event box. So I packed my widget
> into an event box and figured out that I need to put the eventbox
> "above" in order to catch all the events. That all works find and I
> can now catch right click and any other event in the eventbox. But I
> was then stuck on how to get the eventbox to pass on events that it
> does not want to handle into its child widget. This is against normal
> gtk behaviour that only passes events from a child to a parent, and
> not the other way around. I realize that if I manage to pass an event
> from the parent eventbox to the child, I will have to make some
> mechanism to break recursion so that the child will pass on the event
> to the parent that passes the event to the child, ad out-of-memory
> crash.

You can pass on a current (real) event with gtk_widget_event(), but
there is almost certainly something wrong with your code.  Using
gtk_widget_event() for this purpose will in effect pass the
event from one GdkWindow object to another GdkWindow object, when that
other one, because it is the window of a widget which you say is a child
of the one passing it on, is fully capable of receiving it by itself in
the first place.  gtk_widget_event() can be useful in certain limited
cases to pass events to widgets which are not direct children of the
recipient (I have used it to pass on keyboard events to a GtkTextView
object), but inserting a widget which already has a GdkWindow in an
additional event box is not going to change things.

GtkEventBox is for objects which do not have their own GdkWindow, but
almost all widgets do (GtkLabel being an exception). Possibly you
needed to add the relevant event to the event mask of the widget
concerned with gtk_widget_add_events().

You probably need to find out what is wrong with your code in the
first place.

Chris



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