[pygtk] Problem with leave_notify_event
Nathaniel Smith
njs at pobox.com
Sun Jan 20 10:23:20 WST 2008
On Sat, Jan 19, 2008 at 10:05:47AM -0500, Gary Jaffe wrote:
> window.add_events(gtk.gdk.LEAVE_NOTIFY_MASK)
> window.connect("leave_notify_event", self.shrink)
>
> This works. When the pointer leaves the window, self.shrink gets called.
>
> But self.shrink also gets called when the pointer goes from the
> gtk.TreeView to the scrollbar, which is still inside the window.
> Nothing else is calling self.shrink. Is there something special I have
> to do to get the leave_notify_event to trigger only when the pointer
> leaves the window and not when it leaves the gtk.TreeView but stays
> inside the window?
Welcome to the wild world of X events :-). I recommend RFC1013 as a
reference on these things (search for the section on "EnterNotify and
LeaveNotify").
For your case, you need to check the "detail" field of the LeaveNotify
event structure, and ignore some events (for instance, the event that
tells you that the pointer has moved from your window proper into a
child window of your window proper). I *think* this comes down to
"ignore all events with detail == GDK_NOTIFY_INFERIOR", but see
RFC1013 for details.
-- Nathaniel
--
Electrons find their paths in subtle ways.
More information about the pygtk
mailing list