Skip to content

Commit 23ace25

Browse files
authored
Merge pull request #13481 from ronso0/kbd-macos-num-fix
(fix) avoid catching Num key modifier on macOS
2 parents 399846b + 73b9b5e commit 23ace25

1 file changed

Lines changed: 23 additions & 21 deletions

File tree

src/controllers/keyboard/keyboardeventfilter.cpp

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -125,35 +125,37 @@ QKeySequence KeyboardEventFilter::getKeySeq(QKeyEvent* e) {
125125
return {};
126126
}
127127

128+
// Note: test for individual modifiers, don't use e->modifiers() for composing
129+
// the QKeySequence because on macOS arrow key events are sent with the Num
130+
// modifier for some reason. This result in a key sequence for which there
131+
// would be no match in our keyseq/control hash.
132+
// See https://github.com/mixxxdj/mixxx/issues/13305
133+
QString modseq;
134+
if (e->modifiers() & Qt::ShiftModifier) {
135+
modseq += "Shift+";
136+
}
137+
if (e->modifiers() & Qt::ControlModifier) {
138+
modseq += "Ctrl+";
139+
}
140+
if (e->modifiers() & Qt::AltModifier) {
141+
modseq += "Alt+";
142+
}
143+
if (e->modifiers() & Qt::MetaModifier) {
144+
modseq += "Meta+";
145+
}
146+
147+
const QString keyseq = QKeySequence(e->key()).toString();
148+
const QKeySequence k = QKeySequence(modseq + keyseq);
149+
128150
if (CmdlineArgs::Instance().getDeveloper()) {
129-
QString modseq;
130-
QKeySequence k;
131-
if (e->modifiers() & Qt::ShiftModifier) {
132-
modseq += "Shift+";
133-
}
134-
if (e->modifiers() & Qt::ControlModifier) {
135-
modseq += "Ctrl+";
136-
}
137-
if (e->modifiers() & Qt::AltModifier) {
138-
modseq += "Alt+";
139-
}
140-
if (e->modifiers() & Qt::MetaModifier) {
141-
modseq += "Meta+";
142-
}
143-
QString keyseq = QKeySequence(e->key()).toString();
144-
k = QKeySequence(modseq + keyseq);
145151
if (e->type() == QEvent::KeyPress) {
146152
qDebug() << "keyboard press: " << k.toString();
147153
} else if (e->type() == QEvent::KeyRelease) {
148154
qDebug() << "keyboard release: " << k.toString();
149155
}
150156
}
151157

152-
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
153-
return QKeySequence(e->modifiers() | e->key());
154-
#else
155-
return QKeySequence(e->modifiers() + e->key());
156-
#endif
158+
return k;
157159
}
158160

159161
void KeyboardEventFilter::setKeyboardConfig(ConfigObject<ConfigValueKbd>* pKbdConfigObject) {

0 commit comments

Comments
 (0)