Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with key modifiers (holding down keys in GUI to change behavior) after port to Py3/Qt5 #97

Open
megies opened this issue Nov 13, 2020 · 0 comments

Comments

@megies
Copy link
Owner

megies commented Nov 13, 2020

This is just a reminder that there seem to be some problems in some cases where PyQt5.QtCore.Qt.ShiftModifier (enum with integer value 33554432) does not match the key number emitted by holding shift.

A quick hack is to modify the code, but curious how this happens..

Use the above logging to find out what holding shift emits as modifier value and hardcode it below to make holding shift in the GUI work again..

diff --git a/obspyck/obspyck.py b/obspyck/obspyck.py
index 42cf70a..040ac5a 100755
--- a/obspyck/obspyck.py
+++ b/obspyck/obspyck.py
@@ -1827,6 +1827,7 @@ class ObsPyck(QtWidgets.QMainWindow):
         (bottom, top) = ax.get_ybound()
         # Get the keyboard modifiers. They are a enum type.
         # Use bitwise or to compare...hope this is correct.
+        self.critical("%d" % ev.modifiers())
         if ev.modifiers() == QtCore.Qt.NoModifier:
             # Zoom in.
             if ev.angleDelta().y() < 0:
@@ -1843,8 +1844,7 @@ class ObsPyck(QtWidgets.QMainWindow):
                     top += (mpl_ev.ydata - top) / 2
                     bottom -= (bottom - mpl_ev.ydata) / 2
         # Still able to use the dictionary.
-        elif ev.modifiers() == getattr(QtCore.Qt,
-                '%sModifier' % self.keys['switchWheelZoomAxis'].capitalize()):
+        elif int(ev.modifiers()) == 33554432:
             if self.widgets.qToolButton_spectrogram.isChecked():
             # Zoom in on wheel-up
                 if ev.angleDelta().y() < 0:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant