diff options
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 4 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview_complextext.mm | 22 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview_keys.mm | 4 |
3 files changed, 17 insertions, 13 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index c3884414e6..c1c11d5629 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -140,7 +140,6 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSViewMouseMoveHelper); QSet<quint32> m_acceptedKeyDowns; // Text - NSString *m_inputSource; QString m_composingText; QPointer<QObject> m_composingFocusObject; } @@ -165,8 +164,6 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSViewMouseMoveHelper); m_sendKeyEvent = false; m_resendKeyEvent = false; m_currentlyInterpretedKeyEvent = nil; - - m_inputSource = nil; } return self; } @@ -175,7 +172,6 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSViewMouseMoveHelper); { qCDebug(lcQpaWindow) << "Deallocating" << self; - [m_inputSource release]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [m_mouseMoveHelper release]; diff --git a/src/plugins/platforms/cocoa/qnsview_complextext.mm b/src/plugins/platforms/cocoa/qnsview_complextext.mm index b6f082c515..d9df96e0cd 100644 --- a/src/plugins/platforms/cocoa/qnsview_complextext.mm +++ b/src/plugins/platforms/cocoa/qnsview_complextext.mm @@ -68,11 +68,23 @@ qCDebug(lcQpaKeys).nospace() << "Inserting \"" << text << "\"" << ", replacing range " << replacementRange; - if (m_sendKeyEvent && m_composingText.isEmpty() && [text isEqualToString:m_inputSource]) { - // We do not send input method events for simple text input, - // and instead let handleKeyEvent send the key event. - qCDebug(lcQpaKeys) << "Not sending simple text as input method event"; - return; + if (m_sendKeyEvent && m_composingText.isEmpty()) { + // The input method may have transformed the incoming key event + // to text that doesn't match what the original key event would + // have produced, for example when 'Pinyin - Simplified' does smart + // replacement of quotes. If that's the case we can't rely on + // handleKeyEvent for sending the text. + auto *currentEvent = NSApp.currentEvent; + NSString *eventText = currentEvent.type == NSEventTypeKeyDown + || currentEvent.type == NSEventTypeKeyUp + ? currentEvent.characters : nil; + + if ([text isEqualToString:eventText]) { + // We do not send input method events for simple text input, + // and instead let handleKeyEvent send the key event. + qCDebug(lcQpaKeys) << "Ignoring text insertion for simple text"; + return; + } } QObject *focusObject = m_platformWindow->window()->focusObject(); diff --git a/src/plugins/platforms/cocoa/qnsview_keys.mm b/src/plugins/platforms/cocoa/qnsview_keys.mm index 762dc127cc..9fcd30d5d8 100644 --- a/src/plugins/platforms/cocoa/qnsview_keys.mm +++ b/src/plugins/platforms/cocoa/qnsview_keys.mm @@ -50,10 +50,6 @@ NSString *charactersIgnoringModifiers = nsevent.charactersIgnoringModifiers; NSString *characters = nsevent.characters; - if (m_inputSource != characters) { - [m_inputSource release]; - m_inputSource = [characters retain]; - } // Scan codes are hardware dependent codes for each key. There is no way to get these // from Carbon or Cocoa, so leave it 0, as documented in QKeyEvent::nativeScanCode(). |