Re: ToggleButton seems to suppress pointer-motion-mask events

On Feb 3, 2008, at 3:26 PM, Mitchell Laks wrote:

I noticed that initially I could not seem to capture the [pointer motion] events. I am a beginner so I was modifying the examples I found in the distribution files; Thus I was using a widget that a modification of the default example in the Gtk2-GLext package which is composed of a OpenGL endowed DrawingArea that was placed into vbox, (together with a label) and then placed into a ToggleButton.

Why put the DrawingArea inside a ToggleButton? I think that quite violates the Principle of Least Surprise for the user. Every time i'd try to click on the DrawingArea to manipulate the GL objects inside, the ToggleButton would toggle. That's... a bit strange. ;-)

When I tried to add motion-mask or motion-hint-masks via set_events or add_events to the DrawingArea, it never reported the events.

I could only get the events when I thought to get rid of the ToggleButton.

A ToggleButton responds to events, so it has a GdkWindow (which is, in effect, an X Window). The DrawingArea is a simple way to have a GdkWindow on which to draw and get events (so it, to, has an X Window).

When you gtk_widget_add() the DrawingArea to the ToggleButton, you make the DrawingArea's GdkWindow a child of the ToggleButton's GdkWindow. That means that the ToggleButton's GdkWindow gets first crack at all the events. Normally, all you put inside a toggle button are no-window widgets, like GtkLabel or GtkImage, so this isn't a problem.

But in your case, the system is behaving as designed, and the ToggleButton is eating the events that you want to go to the DrawingArea.

Solution:  Don't put the DrawingArea inside a ToggleButton.

Diane, ten-oh-three, Great Northern Hotel.
Sheriff Truman and I have just been with the one-armed man, or what's left of him. In another time, another culture, he may have been a seer, or a shaman priest, but in our world, he's a shoe salesman, and lives among the shadows.
-- Special Agent Dale Cooper

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