John Hunter schrieb:
I recently added support for a figure/axes enter/leave event.  The
figure enter and axes enter/leave are easy to do with nothing new in
the backends, just using the native mpl events.  The figure leave
event is harder, because when a user leaves a figure and activates
another window, mpl gets no events.

To correct this, I added a leave_notify_event method to
backend_bases.FigureCanvasBase (note this is not an mpl Event) but
when called it will trigger a callback to those registered to the
figure_leave_event with the last event that occurred in the window.

I added support for this in gtk by connecting the the gtk signal
'leave_notify_event' to the mpl backend method leave_notify_event.  If
you know something about tk, wx or qt event handling, could you add a
similar method to the appropriate backend?  You can follow the example
in backend_gtk.


You can test with examples/event_handling/figure_axes_enter_leave.py

Thanks,
JDH
I attached a patch for the wx backend. Nearly everything has already been implemented. Instead of the new 'leave_notify_event' leaving the figure triggered a fake motion_event. I changed this.

If a mouse button is pressed while leaving the figure the behaviour is somewhat strange. First, a figure_leave_event is emitted. Then, further moving the mouse outside the figure a new figure_enter_event is created. This is the case since all mouse events, also movements outside the window, are captured as long as a mouse button is pressed. This is a very convenient behaviour for panning/zooming. However, when finally releasing the mouse button no figure_leave_event is triggered. With the GTK backend such an event is created.
So what should be the desired behaviour?

Gregor
Index: backend_wx.py
===================================================================
--- backend_wx.py       (revision 6465)
+++ backend_wx.py       (working copy)
@@ -1263,10 +1263,10 @@
         FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=evt)
 
     def _onLeave(self, evt):
-        """Mouse has left the window; fake a motion event."""
+        """Mouse has left the window."""
 
         evt.Skip()
-        FigureCanvasBase.motion_notify_event(self, -1, -1, guiEvent=evt)
+        FigureCanvasBase.leave_notify_event(self, guiEvent = evt)
 
 
 ########################################################################
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to