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 6c8773c

Browse filesBrowse files
committed
Move emission of axes_enter/leave_event to a separate handler.
1 parent 1c049eb commit 6c8773c
Copy full SHA for 6c8773c

File tree

Expand file treeCollapse file tree

2 files changed

+19
-17
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-17
lines changed

‎lib/matplotlib/backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+16-16Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,22 +1344,6 @@ def __init__(self, name, canvas, x, y, guiEvent=None):
13441344
self.xdata = xdata
13451345
self.ydata = ydata
13461346

1347-
def _process(self):
1348-
last = LocationEvent.lastevent
1349-
last_axes = last.inaxes if last is not None else None
1350-
if last_axes != self.inaxes:
1351-
if last_axes is not None:
1352-
try:
1353-
last.canvas.callbacks.process("axes_leave_event", last)
1354-
except Exception:
1355-
# The last canvas may already have been torn down.
1356-
pass
1357-
if self.inaxes is not None:
1358-
self.canvas.callbacks.process("axes_enter_event", self)
1359-
LocationEvent.lastevent = (
1360-
None if self.name == "figure_leave_event" else self)
1361-
super()._process()
1362-
13631347

13641348
class MouseButton(IntEnum):
13651349
LEFT = 1
@@ -1550,6 +1534,22 @@ def _process(self):
15501534
super()._process()
15511535

15521536

1537+
def _axes_enter_leave_emitter(event):
1538+
last = LocationEvent.lastevent
1539+
last_axes = last.inaxes if last is not None else None
1540+
if last_axes != event.inaxes:
1541+
if last_axes is not None:
1542+
try:
1543+
last.canvas.callbacks.process("axes_leave_event", last)
1544+
except Exception:
1545+
# The last canvas may already have been torn down.
1546+
pass
1547+
if event.inaxes is not None:
1548+
event.canvas.callbacks.process("axes_enter_event", event)
1549+
LocationEvent.lastevent = (
1550+
None if event.name == "figure_leave_event" else event)
1551+
1552+
15531553
def _get_renderer(figure, print_method=None):
15541554
"""
15551555
Get the renderer that would be used to save a `.Figure`, and cache it on

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import numpy as np
2424

2525
import matplotlib as mpl
26-
from matplotlib import _blocking_input, _docstring, projections
26+
from matplotlib import _blocking_input, backend_bases, _docstring, projections
2727
from matplotlib.artist import (
2828
Artist, allow_rasterization, _finalize_rasterization)
2929
from matplotlib.backend_bases import (
@@ -2376,6 +2376,8 @@ def __init__(self,
23762376
'button_press_event', lambda event: self.canvas.pick(event))
23772377
self._scroll_pick_id = self._canvas_callbacks.connect(
23782378
'scroll_event', lambda event: self.canvas.pick(event))
2379+
self._axes_enter_leave_id = self._canvas_callbacks.connect(
2380+
'motion_notify_event', backend_bases._axes_enter_leave_emitter)
23792381

23802382
if figsize is None:
23812383
figsize = mpl.rcParams['figure.figsize']

0 commit comments

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