propogating events not handled by the grab window
- From: "Darren Hart" <darren dvhart com>
- To: gtk-list gnome org
- Subject: propogating events not handled by the grab window
- Date: Tue, 21 Oct 2008 21:56:51 -0700
I've written a custom widget which pops up a
gtk.Window(gtk.WINDOW_POPUP) when the toggle button is pressed. I'm
struggling with the owner_events argument to pointer_grab. If I set
it to True, then my window will stay popped up if I click on active
areas of my main window (i/e/ widgets and not just dead space between
widgets). If I set it to False, then it disappears as it should, but
if I click on any of the controls in the popup, nothing happens. I
thought that by returning False from the popup_button_press handler,
that the event should be propogated to the child widgets... but
apparently not.
What can I do so that if I click anywhere outside the popup the
window, the popup window will close, and if I click inside the popup
window, the appropriate child widget will receive the event? I've
pasted what I believe to be the relevant buts below:
(my example is in python, but I think the concept applies to any
language binding, and I'm not getting a response in pygtk-landia)
def _hide_popup(self):
self._popup.hide()
self._popup.grab_remove()
self.set_active(False)
def _show_popup(self):
x, y = self.window.get_origin()
x += self.get_allocation().x
y += self.get_allocation().y + self.get_allocation().height
self._popup.move(x, y)
self._popup.show_all()
# FIXME: would like second arg to be False, but then the event
doesn't get
# handled if it lands on the popup window... weird...
gdk.pointer_grab(self._popup.window, True,
gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK)
def _on_popup_button_press(self, popup, event):
w, h = popup.get_size()
x = event.x
y = event.y
if x < 0 or x > w or y < 0 or y > h:
self._hide_popup()
return True
# FIXME: this doesn't seem to propogate the events...
return False
Thanks for looking!
--
Darren Hart
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]