Skip to content

Commit

Permalink
(fix) avoid catching Num key modifier on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Jul 18, 2024
1 parent 399846b commit 93a82ae
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/controllers/keyboard/keyboardeventfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,35 +125,37 @@ QKeySequence KeyboardEventFilter::getKeySeq(QKeyEvent* e) {
return {};
}

// Note: test for individual modifiers, don't use e->modifiers() for composing
// the QKeySequence because on macOS e->modifiers() would for some reason
// include the Num modifier for arrow keys which results in a key sequence
// for which there would be no match in our keyseq/control hash.
// See https://github.com/mixxxdj/mixxx/issues/13305
QString modseq;
if (e->modifiers() & Qt::ShiftModifier) {
modseq += "Shift+";
}
if (e->modifiers() & Qt::ControlModifier) {
modseq += "Ctrl+";
}
if (e->modifiers() & Qt::AltModifier) {
modseq += "Alt+";
}
if (e->modifiers() & Qt::MetaModifier) {
modseq += "Meta+";
}

const QString keyseq = QKeySequence(e->key()).toString();
const QKeySequence k = QKeySequence(modseq + keyseq);

if (CmdlineArgs::Instance().getDeveloper()) {
QString modseq;
QKeySequence k;
if (e->modifiers() & Qt::ShiftModifier) {
modseq += "Shift+";
}
if (e->modifiers() & Qt::ControlModifier) {
modseq += "Ctrl+";
}
if (e->modifiers() & Qt::AltModifier) {
modseq += "Alt+";
}
if (e->modifiers() & Qt::MetaModifier) {
modseq += "Meta+";
}
QString keyseq = QKeySequence(e->key()).toString();
k = QKeySequence(modseq + keyseq);
if (e->type() == QEvent::KeyPress) {
qDebug() << "keyboard press: " << k.toString();
} else if (e->type() == QEvent::KeyRelease) {
qDebug() << "keyboard release: " << k.toString();
}
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return QKeySequence(e->modifiers() | e->key());
#else
return QKeySequence(e->modifiers() + e->key());
#endif
return k;
}

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

0 comments on commit 93a82ae

Please sign in to comment.