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

Skip to content

Commit 5f2129f

Browse files
authored
Merge pull request #14082 from anntzer/tkmousemove
In tk backend, don't try to update mouse position after resize.
2 parents 77c864f + b8d7335 commit 5f2129f

File tree

1 file changed

+0
-68
lines changed

1 file changed

+0
-68
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -255,74 +255,6 @@ def resize(self, event):
255255
self.resize_event()
256256
self.draw()
257257

258-
# a resizing will in general move the pointer position
259-
# relative to the canvas, so process it as a motion notify
260-
# event. An intended side effect of this call is to allow
261-
# window raises (which trigger a resize) to get the cursor
262-
# position to the mpl event framework so key presses which are
263-
# over the axes will work w/o clicks or explicit motion
264-
self._update_pointer_position(event)
265-
266-
def _update_pointer_position(self, guiEvent=None):
267-
"""
268-
Figure out if we are inside the canvas or not and update the
269-
canvas enter/leave events
270-
"""
271-
# if the pointer if over the canvas, set the lastx and lasty
272-
# attrs of the canvas so it can process event w/o mouse click
273-
# or move
274-
275-
# the window's upper, left coords in screen coords
276-
xw = self._tkcanvas.winfo_rootx()
277-
yw = self._tkcanvas.winfo_rooty()
278-
# the pointer's location in screen coords
279-
xp, yp = self._tkcanvas.winfo_pointerxy()
280-
281-
# not figure out the canvas coordinates of the pointer
282-
xc = xp - xw
283-
yc = yp - yw
284-
285-
# flip top/bottom
286-
yc = self.figure.bbox.height - yc
287-
288-
# JDH: this method was written originally to get the pointer
289-
# location to the backend lastx and lasty attrs so that events
290-
# like KeyEvent can be handled without mouse events. e.g., if
291-
# the cursor is already above the axes, then key presses like
292-
# 'g' should toggle the grid. In order for this to work in
293-
# backend_bases, the canvas needs to know _lastx and _lasty.
294-
# There are three ways to get this info the canvas:
295-
#
296-
# 1) set it explicitly
297-
#
298-
# 2) call enter/leave events explicitly. The downside of this
299-
# in the impl below is that enter could be repeatedly
300-
# triggered if the mouse is over the axes and one is
301-
# resizing with the keyboard. This is not entirely bad,
302-
# because the mouse position relative to the canvas is
303-
# changing, but it may be surprising to get repeated entries
304-
# without leaves
305-
#
306-
# 3) process it as a motion notify event. This also has pros
307-
# and cons. The mouse is moving relative to the window, but
308-
# this may surprise an event handler writer who is getting
309-
# motion_notify_events even if the mouse has not moved
310-
311-
# here are the three scenarios
312-
if 1:
313-
# just manually set it
314-
self._lastx, self._lasty = xc, yc
315-
elif 0:
316-
# alternate implementation: process it as a motion
317-
FigureCanvasBase.motion_notify_event(self, xc, yc, guiEvent)
318-
elif 0:
319-
# alternate implementation -- process enter/leave events
320-
# instead of motion/notify
321-
if self.figure.bbox.contains(xc, yc):
322-
self.enter_notify_event(guiEvent, xy=(xc, yc))
323-
else:
324-
self.leave_notify_event(guiEvent)
325-
326258
def draw_idle(self):
327259
# docstring inherited
328260
if not self._idle:

0 commit comments

Comments
 (0)