UI: Fix hotkey settings screen not accepting all input on macOS

By default Qt will hand off key events to platform-native input methods
on macOS because the OS or additional software can intercept key input
and transform it (e.g. the international variations popping up when
holding down the key for certain letters).

This functionality can lead to certain key combinations being ignored
because they don't call the delegate methods implemented by Qt to
handle the input after it's been interpreted by the Input Method.

Disabling Input Methods for hotkey input fields fixes this issue, as the
native input methods are bypassed entirely and the key events are
handled by the widget and its keyboard events directly.
This commit is contained in:
PatTheMav 2022-09-10 21:28:29 +02:00 committed by Jim
parent 1a7e5babc2
commit c01d6bf4f7
2 changed files with 10 additions and 0 deletions

View file

@ -59,6 +59,15 @@ void OBSHotkeyEdit::keyPressEvent(QKeyEvent *event)
HandleNewKey(new_key);
}
QVariant OBSHotkeyEdit::inputMethodQuery(Qt::InputMethodQuery query) const
{
if (query == Qt::ImEnabled) {
return false;
} else {
return QLineEdit::inputMethodQuery(query);
}
}
#ifdef __APPLE__
void OBSHotkeyEdit::keyReleaseEvent(QKeyEvent *event)
{

View file

@ -98,6 +98,7 @@ public:
void UpdateDuplicationState();
bool hasDuplicate = false;
QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
protected:
OBSSignal layoutChanged;