浏览代码

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.
PatTheMav 3 年之前
父节点
当前提交
c01d6bf4f7
共有 2 个文件被更改,包括 10 次插入0 次删除
  1. 9 0
      UI/hotkey-edit.cpp
  2. 1 0
      UI/hotkey-edit.hpp

+ 9 - 0
UI/hotkey-edit.cpp

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

+ 1 - 0
UI/hotkey-edit.hpp

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