wip guard wheel guard
CI / lint (push) Skipped
CI / test (3.11) (push) Skipped
CI / test (3.12) (push) Skipped
CI / test (3.13) (push) Skipped
CI / test-with-beamline-plugins (pxi_bec) (push) Skipped
CI / test-with-beamline-plugins (pxii_bec) (push) Skipped
CI / test-with-beamline-plugins (pxiii_bec) (push) Skipped
CI / lint (pull_request) Failing after 47s
CI / test (3.11) (pull_request) Successful in 1m47s
CI / test (3.13) (pull_request) Successful in 1m45s
CI / test (3.12) (pull_request) Successful in 1m50s
CI / test-with-beamline-plugins (pxi_bec) (pull_request) Successful in 1m49s
CI / test-with-beamline-plugins (pxii_bec) (pull_request) Successful in 1m59s
CI / test-with-beamline-plugins (pxiii_bec) (pull_request) Successful in 2m1s
CI / test-with-coverage (pull_request) Successful in 2m30s
CI / coverage-analysis (pull_request) Successful in 4s

This commit is contained in:
2026-08-14 10:09:37 +02:00
parent aa6c226103
commit 47449132e1
+24 -20
View File
@@ -26,26 +26,30 @@ class WheelValueGuard(QObject):
GUARDED = (QAbstractSpinBox, QSlider, QDial, QComboBox, QTabBar)
def eventFilter(self, obj, event):
if event.type() == QEvent.Type.Wheel and isinstance(obj, self.GUARDED):
if event.buttons() & Qt.MouseButton.RightButton:
return False # right button held: deliberate value adjustment
area = obj.parentWidget()
while area is not None and not isinstance(area, QAbstractScrollArea):
area = area.parentWidget()
if area is not None:
relayed = QWheelEvent(
area.viewport().mapFromGlobal(event.globalPosition()),
event.globalPosition(),
event.pixelDelta(),
event.angleDelta(),
event.buttons(),
event.modifiers(),
event.phase(),
event.inverted(),
)
QApplication.sendEvent(area.viewport(), relayed)
return True
return super().eventFilter(obj, event)
try:
if event.type() == QEvent.Type.Wheel and isinstance(obj, self.GUARDED):
if event.buttons() & Qt.MouseButton.RightButton:
return False # right button held: deliberate value adjustment
area = obj.parentWidget()
while area is not None and not isinstance(area, QAbstractScrollArea):
area = area.parentWidget()
if area is not None:
relayed = QWheelEvent(
area.viewport().mapFromGlobal(event.globalPosition()),
event.globalPosition(),
event.pixelDelta(),
event.angleDelta(),
event.buttons(),
event.modifiers(),
event.phase(),
event.inverted(),
)
QApplication.sendEvent(area.viewport(), relayed)
return True
return super().eventFilter(obj, event)
except Exception as e:
print(e)
return False
if __name__ == "__main__":