Routing scroll events in a Gtk.Overlay

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

 



Hi all,

I'm working on a Gtk project (3.10, Python 2 for the prototype, if that matters) using a Gtk.Overlay [1]. The main child of the overlay is a WebKit.WebView. The overlaid widget is a Gtk.EventBox that contains a number of children, grand-children, etc. Right now, scroll events outside of the EventBox go to the WebView, as desired, but scroll events inside the EventBox go to one of it's children. Instead, I would like all of these scroll events to go to the WebView as well, so scrolling doesn't break when the EventBox moves under the pointer.

The only way I've gotten this to work is to recursively attach a scroll-event handler to all the descendants of the EventBox that stops the event and instead creates a scroll event on the WebView. This works, but it's inelegant. I'm hoping there's a way to do this more simply, whether through the EventBox or the Overlay itself.

One idea that sort of worked was to set EventBox.set_above_child(True). This ensured that the EventBox got all the scroll events over any of its descendants, so it was easy to pass them on to the WebView. But it also captured all other events, which I want to go through to the children. Is there some way to tell the EventBox to only capture scroll events? Or is there another way to do this?

Thanks,
Robert

[1] Well, actually the Overlay is a custom class inheriting from Gtk.Overlay and implementing Gtk.Scrollable by passing through the adjustments of the WebView. This is to allow the whole thing to sit in a Gtk.ScrolledWindow that moves both the WebView and the overlaid widget together. I hope that doesn't make a difference, but maybe it does.


_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list




[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux