summaryrefslogtreecommitdiff
path: root/Lib/idlelib/editor.py
diff options
context:
space:
mode:
authorGeeTransit <geetransit@gmail.com>2019-09-04 21:33:34 -0400
committerTerry Jan Reedy <tjreedy@udel.edu>2019-09-04 21:33:33 -0400
commit2cd902585815582eb059e3b40e014ebe4e7fdee7 (patch)
tree67a45372bd87b7d0020e6c5fdcbf034dc417ad8f /Lib/idlelib/editor.py
parent87bd2071c756188b6cd577889fb1682831142ceb (diff)
downloadcpython-git-2cd902585815582eb059e3b40e014ebe4e7fdee7.tar.gz
bpo-37902: IDLE: Add scrolling for IDLE browsers. (#15368)
Modify the wheel event handler so it can also be used for module, path, and stack browsers. Patch by George Zhang.
Diffstat (limited to 'Lib/idlelib/editor.py')
-rw-r--r--Lib/idlelib/editor.py25
1 files changed, 5 insertions, 20 deletions
diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py
index 793ed3afae..5cbf704ab2 100644
--- a/Lib/idlelib/editor.py
+++ b/Lib/idlelib/editor.py
@@ -26,6 +26,7 @@ from idlelib import pyparse
from idlelib import query
from idlelib import replace
from idlelib import search
+from idlelib.tree import wheel_event
from idlelib import window
# The default tab setting for a Text widget, in average-width characters.
@@ -151,9 +152,10 @@ class EditorWindow(object):
else:
# Elsewhere, use right-click for popup menus.
text.bind("<3>",self.right_menu_event)
- text.bind('<MouseWheel>', self.mousescroll)
- text.bind('<Button-4>', self.mousescroll)
- text.bind('<Button-5>', self.mousescroll)
+
+ text.bind('<MouseWheel>', wheel_event)
+ 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)
@@ -502,23 +504,6 @@ class EditorWindow(object):
self.text.yview(event, *args)
return 'break'
- def mousescroll(self, event):
- """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] else 5
- self.text.yview_scroll(lines, 'units')
- return 'break'
-
rmenu = None
def right_menu_event(self, event):