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

Commitee5710c

Browse files
committed
Move lastevent handling to LocationEvent.process.
1 parent136c867 commitee5710c

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
@@ -1350,7 +1350,7 @@ class LocationEvent(Event):
13501350
y data coordinate of the mouse.
13511351
"""
13521352

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

13551355
def__init__(self,name,canvas,x,y,guiEvent=None):
13561356
"""
@@ -1367,7 +1367,6 @@ def __init__(self, name, canvas, x, y, guiEvent=None):
13671367

13681368
ifxisNoneoryisNone:
13691369
# cannot check if event was in axes if no (x, y) info
1370-
self._update_enter_leave()
13711370
return
13721371

13731372
ifself.canvas.mouse_grabberisNone:
@@ -1385,33 +1384,21 @@ def __init__(self, name, canvas, x, y, guiEvent=None):
13851384
self.xdata=xdata
13861385
self.ydata=ydata
13871386

1388-
self._update_enter_leave()
1389-
1390-
def_update_enter_leave(self):
1391-
"""Process the figure/axes enter leave events."""
1392-
ifLocationEvent.lasteventisnotNone:
1393-
last=LocationEvent.lastevent
1394-
iflast.inaxes!=self.inaxes:
1395-
# process axes enter/leave events
1387+
defprocess(self):
1388+
last=LocationEvent.lastevent
1389+
last_axes=last.inaxesiflastisnotNoneelseNone
1390+
iflast_axes!=self.inaxes:
1391+
iflast_axesisnotNone:
13961392
try:
1397-
iflast.inaxesisnotNone:
1398-
last.canvas.callbacks.process('axes_leave_event',last)
1393+
last.canvas.callbacks.process("axes_leave_event",last)
13991394
exceptException:
1395+
# The last canvas may already have been torn down.
14001396
pass
1401-
# See ticket 2901582.
1402-
# I think this is a valid exception to the rule
1403-
# against catching all exceptions; if anything goes
1404-
# wrong, we simply want to move on and process the
1405-
# current event.
1406-
ifself.inaxesisnotNone:
1407-
self.canvas.callbacks.process('axes_enter_event',self)
1408-
1409-
else:
1410-
# process a figure enter event
14111397
ifself.inaxesisnotNone:
1412-
self.canvas.callbacks.process('axes_enter_event',self)
1413-
1414-
LocationEvent.lastevent=self
1398+
self.canvas.callbacks.process("axes_enter_event",self)
1399+
LocationEvent.lastevent= (
1400+
Noneifself.name=="figure_leave_event"elseself)
1401+
super().process()
14151402

14161403

14171404
classMouseButton(IntEnum):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp