Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4f5715a

Browse filesBrowse files
authored
Merge pull request #9814 from lkjell/fix_figure_enter_event
figure_enter_event uses now LocationEvent instead of Event. Fix issue #9812.
2 parents b5391ce + 64e37bc commit 4f5715a
Copy full SHA for 4f5715a

File tree

Expand file treeCollapse file tree

5 files changed

+24
-4
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+24
-4
lines changed

‎lib/matplotlib/backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1983,8 +1983,14 @@ def enter_notify_event(self, guiEvent=None, xy=None):
19831983
if xy is not None:
19841984
x, y = xy
19851985
self._lastx, self._lasty = x, y
1986+
else:
1987+
x = None
1988+
y = None
1989+
cbook.warn_deprecated('3.0', 'enter_notify_event expects a '
1990+
'location but '
1991+
'your backend did not pass one.')
19861992

1987-
event = Event('figure_enter_event', self, guiEvent)
1993+
event = LocationEvent('figure_enter_event', self, x, y, guiEvent)
19881994
self.callbacks.process('figure_enter_event', event)
19891995

19901996
def grab_mouse(self, ax):

‎lib/matplotlib/backends/_backend_tk.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/_backend_tk.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ def __init__(self, figure, master=None, resize_callback=None):
178178
self._tkcanvas.bind("<Configure>", self.resize)
179179
self._tkcanvas.bind("<Key>", self.key_press)
180180
self._tkcanvas.bind("<Motion>", self.motion_notify_event)
181+
self._tkcanvas.bind("<Enter>", self.enter_notify_event)
182+
self._tkcanvas.bind("<Leave>", self.leave_notify_event)
181183
self._tkcanvas.bind("<KeyRelease>", self.key_release)
182184
for name in "<Button-1>", "<Button-2>", "<Button-3>":
183185
self._tkcanvas.bind(name, self.button_press_event)
@@ -326,6 +328,11 @@ def motion_notify_event(self, event):
326328
y = self.figure.bbox.height - event.y
327329
FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=event)
328330

331+
def enter_notify_event(self, event):
332+
x = event.x
333+
# flipy so y=0 is bottom of canvas
334+
y = self.figure.bbox.height - event.y
335+
FigureCanvasBase.enter_notify_event(self, guiEvent=event, xy=(x, y))
329336

330337
def button_press_event(self, event, dblclick=False):
331338
x = event.x

‎lib/matplotlib/backends/backend_gtk3.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_gtk3.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@ def leave_notify_event(self, widget, event):
225225
FigureCanvasBase.leave_notify_event(self, event)
226226

227227
def enter_notify_event(self, widget, event):
228-
FigureCanvasBase.enter_notify_event(self, event)
228+
x = event.x
229+
# flipy so y=0 is bottom of canvas
230+
y = self.get_allocation().height - event.y
231+
FigureCanvasBase.enter_notify_event(self, guiEvent=event, xy=(x, y))
229232

230233
def size_allocate(self, widget, allocation):
231234
dpival = self.figure.dpi

‎lib/matplotlib/backends/backend_qt5.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt5.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ def get_width_height(self):
299299
return int(w / self._dpi_ratio), int(h / self._dpi_ratio)
300300

301301
def enterEvent(self, event):
302-
FigureCanvasBase.enter_notify_event(self, guiEvent=event)
302+
x, y = self.mouseEventCoords(event.pos())
303+
FigureCanvasBase.enter_notify_event(self, guiEvent=event, xy=(x, y))
303304

304305
def leaveEvent(self, event):
305306
QtWidgets.QApplication.restoreOverrideCursor()

‎lib/matplotlib/backends/backend_wx.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_wx.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,10 @@ def _onLeave(self, evt):
10321032

10331033
def _onEnter(self, evt):
10341034
"""Mouse has entered the window."""
1035-
FigureCanvasBase.enter_notify_event(self, guiEvent=evt)
1035+
x = evt.GetX()
1036+
y = self.figure.bbox.height - evt.GetY()
1037+
evt.Skip()
1038+
FigureCanvasBase.enter_notify_event(self, guiEvent=evt, xy=(x, y))
10361039

10371040

10381041
class FigureCanvasWx(_FigureCanvasWxBase):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.