Skip to content

Commit 0f8bfe1

Browse files
committed
Merge pull request matplotlib#1320 from efiring/cursor_lock
Cursor widget now uses widgetlock; closes Issue matplotlib#156
2 parents 7f5b005 + 1729a94 commit 0f8bfe1

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lib/matplotlib/widgets.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,8 @@ def onmove(self, event):
841841
'on mouse motion draw the cursor if visible'
842842
if self.ignore(event):
843843
return
844+
if not self.canvas.widgetlock.available(self):
845+
return
844846
if event.inaxes != self.ax:
845847
self.linev.set_visible(False)
846848
self.lineh.set_visible(False)
@@ -907,7 +909,8 @@ def __init__(self, canvas, axes, useblit=True, **lineprops):
907909
if useblit:
908910
lineprops['animated'] = True
909911

910-
self.lines = [ax.axvline(xmid, visible=False, **lineprops) for ax in axes]
912+
self.lines = [ax.axvline(xmid, visible=False, **lineprops)
913+
for ax in axes]
911914

912915
self.visible = True
913916
self.useblit = useblit
@@ -921,15 +924,20 @@ def __init__(self, canvas, axes, useblit=True, **lineprops):
921924
def clear(self, event):
922925
'clear the cursor'
923926
if self.useblit:
924-
self.background = self.canvas.copy_from_bbox(self.canvas.figure.bbox)
925-
for line in self.lines: line.set_visible(False)
927+
self.background = self.canvas.copy_from_bbox(
928+
self.canvas.figure.bbox)
929+
for line in self.lines:
930+
line.set_visible(False)
926931

927932

928933
def onmove(self, event):
929-
if event.inaxes is None: return
930-
if not self.canvas.widgetlock.available(self): return
934+
if event.inaxes is None:
935+
return
936+
if not self.canvas.widgetlock.available(self):
937+
return
931938
self.needclear = True
932-
if not self.visible: return
939+
if not self.visible:
940+
return
933941

934942
for line in self.lines:
935943
line.set_xdata((event.xdata, event.xdata))

0 commit comments

Comments
 (0)