[Python-checkins] bpo-34047: IDLE: fix mousewheel scrolling direction on macOS (GH-8678)
Miss Islington (bot)
webhook-mailer at python.org
Fri Aug 10 02:43:11 EDT 2018
https://github.com/python/cpython/commit/ea8835fb302447da82f265a5bc0f785353100271
commit: ea8835fb302447da82f265a5bc0f785353100271
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-08-09T23:43:06-07:00
summary:
bpo-34047: IDLE: fix mousewheel scrolling direction on macOS (GH-8678)
(cherry picked from commit 077059e0f086cf8c8b7fb9d1f053e38ddc743f59)
Co-authored-by: Tal Einat <taleinat+github at gmail.com>
files:
A Misc/NEWS.d/next/IDLE/2018-08-05-15-49-55.bpo-34047.LGKsIm.rst
M Lib/idlelib/editor.py
diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py
index 1a163891c27d..227a74deb82d 100644
--- a/Lib/idlelib/editor.py
+++ b/Lib/idlelib/editor.py
@@ -457,12 +457,19 @@ def handle_yview(self, event, *args):
return 'break'
def mousescroll(self, event):
- "Handle scroll wheel."
- up = {EventType.MouseWheel: event.delta >= 0 == darwin,
+ """Handle scrollwheel event.
+
+ 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}
- lines = 5
- if up[event.type]:
- lines = -lines
+ lines = -5 if up[event.type] else 5
self.text.yview_scroll(lines, 'units')
return 'break'
@@ -1701,7 +1708,11 @@ def _editor_window(parent): # htest #
filename = None
macosx.setupApp(root, None)
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
# edit.text.bind("<<close-window>>", edit.close_event)
diff --git a/Misc/NEWS.d/next/IDLE/2018-08-05-15-49-55.bpo-34047.LGKsIm.rst b/Misc/NEWS.d/next/IDLE/2018-08-05-15-49-55.bpo-34047.LGKsIm.rst
new file mode 100644
index 000000000000..a247908ba844
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2018-08-05-15-49-55.bpo-34047.LGKsIm.rst
@@ -0,0 +1 @@
+Fixed mousewheel scrolling direction on macOS.
More information about the Python-checkins
mailing list