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

Skip to content

Commit 6c6cab4

Browse files
committed
Fix cursor restoration.
1 parent 78300a9 commit 6c6cab4

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
@@ -2819,7 +2819,8 @@ def __init__(self, canvas):
28192819
self._idPress = None
28202820
self._idRelease = None
28212821
self._active = None
2822-
self._lastCursor = None
2822+
# This cursor will be set after the initial draw.
2823+
self._lastCursor = cursors.POINTER
28232824
self._init_toolbar()
28242825
self._idDrag = self.canvas.mpl_connect(
28252826
'motion_notify_event', self.mouse_move)
@@ -2898,14 +2899,13 @@ def _set_cursor(self, event):
28982899
self.set_cursor(cursors.POINTER)
28992900
self._lastCursor = cursors.POINTER
29002901
else:
2901-
if self._active == 'ZOOM':
2902-
if self._lastCursor != cursors.SELECT_REGION:
2903-
self.set_cursor(cursors.SELECT_REGION)
2904-
self._lastCursor = cursors.SELECT_REGION
2902+
if (self._active == 'ZOOM'
2903+
and self._lastCursor != cursors.SELECT_REGION):
2904+
self.set_cursor(cursors.SELECT_REGION)
2905+
self._lastCursor = cursors.SELECT_REGION
29052906
elif (self._active == 'PAN' and
29062907
self._lastCursor != cursors.MOVE):
29072908
self.set_cursor(cursors.MOVE)
2908-
29092909
self._lastCursor = cursors.MOVE
29102910

29112911
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
@@ -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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)