From 21e28f621e74e4a71eac18cb6997cf0774c04d91 Mon Sep 17 00:00:00 2001 From: kemal Date: Fri, 28 Aug 2026 02:06:22 +0300 Subject: [PATCH] Allow wheel events on focused boxes when window is inactive --- dikte/settings_ui.py | 4 +++- tests/test_ui.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dikte/settings_ui.py b/dikte/settings_ui.py index 56771f8..1bf182e 100644 --- a/dikte/settings_ui.py +++ b/dikte/settings_ui.py @@ -207,7 +207,9 @@ class WheelGuard(QObject): """ def eventFilter(self, box, event): - if event.type() == QEvent.Type.Wheel and not box.hasFocus(): + win = box.window() + focused = box.hasFocus() or (win is not None and win.focusWidget() is box) + if event.type() == QEvent.Type.Wheel and not focused: # Refused rather than swallowed. An unaccepted wheel event carries # on up the parents to the scroll area, so the page still moves. event.ignore() diff --git a/tests/test_ui.py b/tests/test_ui.py index 6273447..038137f 100644 --- a/tests/test_ui.py +++ b/tests/test_ui.py @@ -223,6 +223,17 @@ class Settings(DikteTest): QApplication.sendEvent(box, self.wheel()) self.assertNotEqual(box.currentIndex(), before) + def test_the_wheel_is_refused_when_another_widget_has_focus(self): + window = self.window(cfg.Config()) + box = window.ui_language + other = window.corner + other.setFocus() + before = box.currentIndex() + rolled = self.wheel() + QApplication.sendEvent(box, rolled) + self.assertEqual(box.currentIndex(), before) + self.assertFalse(rolled.isAccepted()) + def test_a_wrapped_label_keeps_the_room_its_lines_need(self): # The program path shares a row with a button, and a row is measured # before its width is known: the label has to claim the second line back