diff --git a/.gitignore b/.gitignore index b83c549..0388aa1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /dist/ +/.idea/ /.vscode/ __pycache__ diff --git a/src/ScrollableContainers/_tk.py b/src/ScrollableContainers/_tk.py index ee1d9cd..b8cdf44 100644 --- a/src/ScrollableContainers/_tk.py +++ b/src/ScrollableContainers/_tk.py @@ -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)