Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ab48cd

Browse files
committed
Fix cursor restoration.
1 parent 5d06137 commit 7ab48cd

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2754,7 +2754,8 @@ def __init__(self, canvas):
27542754
self._idPress = None
27552755
self._idRelease = None
27562756
self._active = None
2757-
self._lastCursor = None
2757+
# This cursor will be set after the initial draw.
2758+
self._lastCursor = cursors.POINTER
27582759
self._init_toolbar()
27592760
self._idDrag = self.canvas.mpl_connect(
27602761
'motion_notify_event', self.mouse_move)
@@ -2829,14 +2830,13 @@ def _set_cursor(self, event):
28292830
self.set_cursor(cursors.POINTER)
28302831
self._lastCursor = cursors.POINTER
28312832
else:
2832-
if self._active == 'ZOOM':
2833-
if self._lastCursor != cursors.SELECT_REGION:
2834-
self.set_cursor(cursors.SELECT_REGION)
2835-
self._lastCursor = cursors.SELECT_REGION
2833+
if (self._active == 'ZOOM'
2834+
and self._lastCursor != cursors.SELECT_REGION):
2835+
self.set_cursor(cursors.SELECT_REGION)
2836+
self._lastCursor = cursors.SELECT_REGION
28362837
elif (self._active == 'PAN' and
28372838
self._lastCursor != cursors.MOVE):
28382839
self.set_cursor(cursors.MOVE)
2839-
28402840
self._lastCursor = cursors.MOVE
28412841

28422842
def mouse_move(self, event):

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def draw(self):
478478
self.figure.draw(self.renderer)
479479
finally:
480480
if toolbar:
481-
toolbar.set_cursor(cursors.POINTER)
481+
toolbar.set_cursor(toolbar._lastCursor)
482482
RendererAgg.lock.release()
483483

484484
def get_renderer(self, cleared=False):

lib/matplotlib/backends/backend_gtk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def expose_event(self, widget, event):
456456
self.window.draw_drawable (self.style.fg_gc[self.state],
457457
self._pixmap, x, y, x, y, w, h)
458458
if toolbar:
459-
toolbar.set_cursor(cursors.POINTER)
459+
toolbar.set_cursor(toolbar._lastCursor)
460460
return False # finish event propagation?
461461

462462
filetypes = FigureCanvasBase.filetypes.copy()

lib/matplotlib/backends/backend_gtk3cairo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def on_draw_event(self, widget, ctx):
4747
x, y, w, h = allocation.x, allocation.y, allocation.width, allocation.height
4848
self._render_figure(w, h)
4949
if toolbar:
50-
toolbar.set_cursor(cursors.POINTER)
50+
toolbar.set_cursor(toolbar._lastCursor)
5151
#self._need_redraw = False
5252

5353
return False # finish event propagation?

0 commit comments

Comments
 (0)