Skip to content

Commit d1516e6

Browse files
committed
Fix cursor restoration.
1 parent 54689d7 commit d1516e6

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

lib/matplotlib/backend_bases.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -2818,7 +2818,8 @@ def __init__(self, canvas):
28182818
self._idPress = None
28192819
self._idRelease = None
28202820
self._active = None
2821-
self._lastCursor = None
2821+
# This cursor will be set after the initial draw.
2822+
self._lastCursor = cursors.POINTER
28222823
self._init_toolbar()
28232824
self._idDrag = self.canvas.mpl_connect(
28242825
'motion_notify_event', self.mouse_move)
@@ -2904,14 +2905,13 @@ def _set_cursor(self, event):
29042905
self.set_cursor(cursors.POINTER)
29052906
self._lastCursor = cursors.POINTER
29062907
else:
2907-
if self._active == 'ZOOM':
2908-
if self._lastCursor != cursors.SELECT_REGION:
2909-
self.set_cursor(cursors.SELECT_REGION)
2910-
self._lastCursor = cursors.SELECT_REGION
2908+
if (self._active == 'ZOOM'
2909+
and self._lastCursor != cursors.SELECT_REGION):
2910+
self.set_cursor(cursors.SELECT_REGION)
2911+
self._lastCursor = cursors.SELECT_REGION
29112912
elif (self._active == 'PAN' and
29122913
self._lastCursor != cursors.MOVE):
29132914
self.set_cursor(cursors.MOVE)
2914-
29152915
self._lastCursor = cursors.MOVE
29162916

29172917
def mouse_move(self, event):

lib/matplotlib/backends/backend_agg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def draw(self):
429429
self.figure.draw(self.renderer)
430430
finally:
431431
if toolbar:
432-
toolbar.set_cursor(cursors.POINTER)
432+
toolbar.set_cursor(toolbar._lastCursor)
433433
RendererAgg.lock.release()
434434

435435
def get_renderer(self, cleared=False):

lib/matplotlib/backends/backend_gtk.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def expose_event(self, widget, event):
400400
self.window.draw_drawable (self.style.fg_gc[self.state],
401401
self._pixmap, x, y, x, y, w, h)
402402
if toolbar:
403-
toolbar.set_cursor(cursors.POINTER)
403+
toolbar.set_cursor(toolbar._lastCursor)
404404
return False # finish event propagation?
405405

406406
filetypes = FigureCanvasBase.filetypes.copy()

lib/matplotlib/backends/backend_gtk3cairo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def on_draw_event(self, widget, ctx):
4444
x, y, w, h = allocation.x, allocation.y, allocation.width, allocation.height
4545
self._render_figure(w, h)
4646
if toolbar:
47-
toolbar.set_cursor(cursors.POINTER)
47+
toolbar.set_cursor(toolbar._lastCursor)
4848
return False # finish event propagation?
4949

5050

0 commit comments

Comments
 (0)