Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitb7c09d5

Browse files
committed
Move lastevent handling to LocationEvent.process.
1 parentb5763fa commitb7c09d5

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

‎lib/matplotlib/backend_bases.py

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ class LocationEvent(Event):
12901290
y data coordinate of the mouse.
12911291
"""
12921292

1293-
lastevent=None#the last eventthat was triggered before this one
1293+
lastevent=None#The last eventprocessed so far.
12941294

12951295
def__init__(self,name,canvas,x,y,guiEvent=None):
12961296
"""
@@ -1307,7 +1307,6 @@ def __init__(self, name, canvas, x, y, guiEvent=None):
13071307

13081308
ifxisNoneoryisNone:
13091309
# cannot check if event was in axes if no (x, y) info
1310-
self._update_enter_leave()
13111310
return
13121311

13131312
ifself.canvas.mouse_grabberisNone:
@@ -1325,33 +1324,21 @@ def __init__(self, name, canvas, x, y, guiEvent=None):
13251324
self.xdata=xdata
13261325
self.ydata=ydata
13271326

1328-
self._update_enter_leave()
1329-
1330-
def_update_enter_leave(self):
1331-
"""Process the figure/axes enter leave events."""
1332-
ifLocationEvent.lasteventisnotNone:
1333-
last=LocationEvent.lastevent
1334-
iflast.inaxes!=self.inaxes:
1335-
# process axes enter/leave events
1327+
defprocess(self):
1328+
last=LocationEvent.lastevent
1329+
last_axes=last.inaxesiflastisnotNoneelseNone
1330+
iflast_axes!=self.inaxes:
1331+
iflast_axesisnotNone:
13361332
try:
1337-
iflast.inaxesisnotNone:
1338-
last.canvas.callbacks.process('axes_leave_event',last)
1333+
last.canvas.callbacks.process("axes_leave_event",last)
13391334
exceptException:
1335+
# The last canvas may already have been torn down.
13401336
pass
1341-
# See ticket 2901582.
1342-
# I think this is a valid exception to the rule
1343-
# against catching all exceptions; if anything goes
1344-
# wrong, we simply want to move on and process the
1345-
# current event.
1346-
ifself.inaxesisnotNone:
1347-
self.canvas.callbacks.process('axes_enter_event',self)
1348-
1349-
else:
1350-
# process a figure enter event
13511337
ifself.inaxesisnotNone:
1352-
self.canvas.callbacks.process('axes_enter_event',self)
1353-
1354-
LocationEvent.lastevent=self
1338+
self.canvas.callbacks.process("axes_enter_event",self)
1339+
LocationEvent.lastevent= (
1340+
Noneifself.name=="figure_leave_event"elseself)
1341+
super().process()
13551342

13561343

13571344
classMouseButton(IntEnum):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp