bpo-34047: IDLE: fix mousewheel scrolling direction on macOS (GH-8678)
(cherry picked from commit 077059e0f0
)
Co-authored-by: Tal Einat <taleinat+github@gmail.com>
This commit is contained in:
parent
56410810d3
commit
ea8835fb30
|
@ -457,12 +457,19 @@ class EditorWindow(object):
|
||||||
return 'break'
|
return 'break'
|
||||||
|
|
||||||
def mousescroll(self, event):
|
def mousescroll(self, event):
|
||||||
"Handle scroll wheel."
|
"""Handle scrollwheel event.
|
||||||
up = {EventType.MouseWheel: event.delta >= 0 == darwin,
|
|
||||||
|
For wheel up, event.delta = 120*n on Windows, -1*n on darwin,
|
||||||
|
where n can be > 1 if one scrolls fast. Flicking the wheel
|
||||||
|
generates up to maybe 20 events with n up to 10 or more 1.
|
||||||
|
Macs use wheel down (delta = 1*n) to scroll up, so positive
|
||||||
|
delta means to scroll up on both systems.
|
||||||
|
|
||||||
|
X-11 sends Control-Button-4 event instead.
|
||||||
|
"""
|
||||||
|
up = {EventType.MouseWheel: event.delta > 0,
|
||||||
EventType.Button: event.num == 4}
|
EventType.Button: event.num == 4}
|
||||||
lines = 5
|
lines = -5 if up[event.type] else 5
|
||||||
if up[event.type]:
|
|
||||||
lines = -lines
|
|
||||||
self.text.yview_scroll(lines, 'units')
|
self.text.yview_scroll(lines, 'units')
|
||||||
return 'break'
|
return 'break'
|
||||||
|
|
||||||
|
@ -1701,7 +1708,11 @@ def _editor_window(parent): # htest #
|
||||||
filename = None
|
filename = None
|
||||||
macosx.setupApp(root, None)
|
macosx.setupApp(root, None)
|
||||||
edit = EditorWindow(root=root, filename=filename)
|
edit = EditorWindow(root=root, filename=filename)
|
||||||
edit.text.bind("<<close-all-windows>>", edit.close_event)
|
text = edit.text
|
||||||
|
text['height'] = 10
|
||||||
|
for i in range(20):
|
||||||
|
text.insert('insert', ' '*i + str(i) + '\n')
|
||||||
|
# text.bind("<<close-all-windows>>", edit.close_event)
|
||||||
# Does not stop error, neither does following
|
# Does not stop error, neither does following
|
||||||
# edit.text.bind("<<close-window>>", edit.close_event)
|
# edit.text.bind("<<close-window>>", edit.close_event)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fixed mousewheel scrolling direction on macOS.
|
Loading…
Reference in New Issue