commit 9eb6961fa97d0c4b205c6881b73e830650bb38c0
Author: Koji Yokota <[email protected]>
Date: Fri Oct 30 19:27:23 2026 +0900
Fix Meta-Q prefixed shortcuts on macOS
The Cocoa text system binds Control-Q (NSQuotedKeystrokeBinding) to
"insert the next keystroke literally" by default. Since Qt passes key
events to the input context first, it consumes physical Control-Q
(Meta-Q in LyX) before a key event is delivered, so bindings like
"M-q <key>" never fire and the second key is inserted as text.
Register an empty NSQuotedKeystrokeBinding to disable it. Being a
registration default, an explicit user setting still takes precedence.
Assisted-by: Claude
---
src/frontends/qt/GuiApplication.cpp | 1 +
src/support/AppleSupport.h | 2 ++
src/support/AppleSupport.m | 11 +++++++++++
3 files changed, 14 insertions(+)
diff --git a/src/frontends/qt/GuiApplication.cpp
b/src/frontends/qt/GuiApplication.cpp
index 25204088b2..13970ff2cd 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -1213,6 +1213,7 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
setupApplescript();
appleCleanupEditMenu();
appleCleanupViewMenu();
+ appleDisableQuotedKeystroke();
connect(this, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
this,
SLOT(onApplicationStateChanged(Qt::ApplicationState)));
#endif
diff --git a/src/support/AppleSupport.h b/src/support/AppleSupport.h
index ccbb5e39cf..b2cfb415f1 100644
--- a/src/support/AppleSupport.h
+++ b/src/support/AppleSupport.h
@@ -17,6 +17,8 @@ extern "C" {
#endif
void appleCleanupEditMenu();
void appleCleanupViewMenu();
+ // stop the Cocoa text system from swallowing Control-Q as "quote next
key"
+ void appleDisableQuotedKeystroke();
// query the system preferences for users tabbing preference
bool appleUserTabbingPreferenceAlways();
diff --git a/src/support/AppleSupport.m b/src/support/AppleSupport.m
index 890cfc29cf..1a70b77856 100644
--- a/src/support/AppleSupport.m
+++ b/src/support/AppleSupport.m
@@ -37,6 +37,17 @@ void appleCleanupViewMenu() {
}
+void appleDisableQuotedKeystroke() {
+ // By default, the Cocoa text system binds Control-Q
(NSQuotedKeystrokeBinding)
+ // to "insert the next keystroke literally". The input context consumes
it
+ // before Qt delivers a key event, so LyX never sees Meta-Q and bindings
+ // like "M-q <key>" cannot work. Register an empty binding to disable
it;
+ // being a registration default, an explicit user setting still wins.
+ [[NSUserDefaults standardUserDefaults] registerDefaults:
+ @{@"NSQuotedKeystrokeBinding": @""}];
+}
+
+
bool appleUserTabbingPreferenceAlways() {
#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED
>= 101200)
return [NSWindow respondsToSelector:@selector(userTabbingPreference)] &&
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs