mirror of https://github.com/python/cpython.git
gh-103820: IDLE: Do not interpret buttons 4/5 as scrolling on non-X11 (GH-103821)
Also fix test_mousewheel: do not skip a check which was broken due to incorrect delta on Aqua and XQuartz, and probably not because of `.update_idletasks()`.
This commit is contained in:
parent
53339a0ef7
commit
d25d4ee60c
|
@ -166,8 +166,9 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
|
|||
text.bind("<3>",self.right_menu_event)
|
||||
|
||||
text.bind('<MouseWheel>', wheel_event)
|
||||
text.bind('<Button-4>', wheel_event)
|
||||
text.bind('<Button-5>', wheel_event)
|
||||
if text._windowingsystem == 'x11':
|
||||
text.bind('<Button-4>', wheel_event)
|
||||
text.bind('<Button-5>', wheel_event)
|
||||
text.bind('<Configure>', self.handle_winconfig)
|
||||
text.bind("<<cut>>", self.cut)
|
||||
text.bind("<<copy>>", self.copy)
|
||||
|
|
|
@ -690,16 +690,22 @@ def test_mousewheel(self):
|
|||
last_lineno = get_end_linenumber(text)
|
||||
self.assertIsNotNone(text.dlineinfo(text.index(f'{last_lineno}.0')))
|
||||
|
||||
# Scroll up using the <MouseWheel> event.
|
||||
# The meaning of delta is platform-dependent.
|
||||
delta = -1 if sys.platform == 'darwin' else 120
|
||||
sidebar.canvas.event_generate('<MouseWheel>', x=0, y=0, delta=delta)
|
||||
yield
|
||||
if sys.platform != 'darwin': # .update_idletasks() does not work.
|
||||
self.assertIsNone(text.dlineinfo(text.index(f'{last_lineno}.0')))
|
||||
# Delta for <MouseWheel>, whose meaning is platform-dependent.
|
||||
delta = 1 if sidebar.canvas._windowingsystem == 'aqua' else 120
|
||||
|
||||
# Scroll back down using the <Button-5> event.
|
||||
sidebar.canvas.event_generate('<Button-5>', x=0, y=0)
|
||||
# Scroll up.
|
||||
if sidebar.canvas._windowingsystem == 'x11':
|
||||
sidebar.canvas.event_generate('<Button-4>', x=0, y=0)
|
||||
else:
|
||||
sidebar.canvas.event_generate('<MouseWheel>', x=0, y=0, delta=delta)
|
||||
yield
|
||||
self.assertIsNone(text.dlineinfo(text.index(f'{last_lineno}.0')))
|
||||
|
||||
# Scroll back down.
|
||||
if sidebar.canvas._windowingsystem == 'x11':
|
||||
sidebar.canvas.event_generate('<Button-5>', x=0, y=0)
|
||||
else:
|
||||
sidebar.canvas.event_generate('<MouseWheel>', x=0, y=0, delta=-delta)
|
||||
yield
|
||||
self.assertIsNotNone(text.dlineinfo(text.index(f'{last_lineno}.0')))
|
||||
|
||||
|
|
|
@ -285,8 +285,9 @@ def drawtext(self):
|
|||
self.label.bind("<1>", self.select_or_edit)
|
||||
self.label.bind("<Double-1>", self.flip)
|
||||
self.label.bind("<MouseWheel>", lambda e: wheel_event(e, self.canvas))
|
||||
self.label.bind("<Button-4>", lambda e: wheel_event(e, self.canvas))
|
||||
self.label.bind("<Button-5>", lambda e: wheel_event(e, self.canvas))
|
||||
if self.label._windowingsystem == 'x11':
|
||||
self.label.bind("<Button-4>", lambda e: wheel_event(e, self.canvas))
|
||||
self.label.bind("<Button-5>", lambda e: wheel_event(e, self.canvas))
|
||||
self.text_id = id
|
||||
|
||||
def select_or_edit(self, event=None):
|
||||
|
@ -460,8 +461,9 @@ def __init__(self, master, **opts):
|
|||
self.canvas.bind("<Key-Up>", self.unit_up)
|
||||
self.canvas.bind("<Key-Down>", self.unit_down)
|
||||
self.canvas.bind("<MouseWheel>", wheel_event)
|
||||
self.canvas.bind("<Button-4>", wheel_event)
|
||||
self.canvas.bind("<Button-5>", wheel_event)
|
||||
if self.canvas._windowingsystem == 'x11':
|
||||
self.canvas.bind("<Button-4>", wheel_event)
|
||||
self.canvas.bind("<Button-5>", wheel_event)
|
||||
#if isinstance(master, Toplevel) or isinstance(master, Tk):
|
||||
self.canvas.bind("<Alt-Key-2>", self.zoom_height)
|
||||
self.canvas.focus_set()
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Revise IDLE bindings so that events from mouse button 4/5 on non-X11
|
||||
windowing systems (i.e. Win32 and Aqua) are not mistaken for scrolling.
|
Loading…
Reference in New Issue