Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/dist/
/.idea/
/.vscode/
__pycache__
18 changes: 11 additions & 7 deletions src/ScrollableContainers/_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,22 @@ def _scroll_viewport(self, event: tk.Event):

:param event: Scroll event.
"""
# Select which method to call based on whether Shift was held down.
# This is indicated by the LSB of the state.
callee = self._xview if event.state & 1 else self._yview
match _system:
case "Linux" if event.num == 4:
callee(tk.SCROLL, -1, tk.UNITS)
amount = -1
case "Linux" if event.num == 5:
callee(tk.SCROLL, 1, tk.UNITS)
amount = 1
case "Darwin":
callee(tk.SCROLL, -event.delta, tk.UNITS)
amount = -event.delta
case "Windows":
callee(tk.SCROLL, -event.delta // 120, tk.UNITS)
amount = -event.delta // 120
case _:
message = f"event {event.num} on OS {_system!r} is not supported"
raise ValueError(message)

# Select the method to call based on whether Shift was held down. This
# is indicated by the LSB of the state.
if event.state & 1:
self._xview(tk.SCROLL, amount, tk.UNITS)
else:
self._yview(tk.SCROLL, amount, tk.UNITS)