mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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.
This commit is contained in:
parent
87bd2071c7
commit
2cd9025858
7 changed files with 78 additions and 21 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue