macOS: Send key press as QKeyEvent if input context doesn't consume it
If IM is enabled we send key events through the macOS text input system, and we do this for all key pressed, including the ones with modifiers pressed. The latter allows the input method to respond to shortcut key combinations to switch its own mode or do more advanced operations on the text. We were relying on the IM to call doCommandBySelector with a noop selector if the shortcut didn't match any of its own internal key sequences, but this fails for key events with more than one modifier pressed. Instead of using [NSView interpretKeyEvents:] to pass the key event to the system IM we now go directly to the NSInputContext, which the former method is just a wrapper for. This allows us to use the result of [NSInputContext handleEvent:] to determine if the system IM consumed the event or not. For key events with multiple modifiers this will be false, which we interpret to send the event as a regular QKeyEvent instead. Fixes: QTBUG-123848 Fixes: QTBUG-106516 Pick-to: 6.5 6.2 Change-Id: I14a43c2029149514515dd9ece881aed3f6500a4e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 085d5db90dd4c148fe5dea6a3435166f6bdeedac) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
3162f7a6ad
commit
79cb221f96
@ -94,7 +94,10 @@ static bool isSpecialKey(const QString &text)
|
||||
|
||||
qCDebug(lcQpaKeys) << "Interpreting key event for focus object" << focusObject;
|
||||
m_currentlyInterpretedKeyEvent = nsevent;
|
||||
[self interpretKeyEvents:@[nsevent]];
|
||||
if (![self.inputContext handleEvent:nsevent]) {
|
||||
qCDebug(lcQpaKeys) << "Input context did not consume event";
|
||||
m_sendKeyEvent = true;
|
||||
}
|
||||
m_currentlyInterpretedKeyEvent = 0;
|
||||
didInterpretKeyEvent = true;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user