summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-05-06 17:00:22 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-05-06 22:01:23 +0200
commitb24da5449bc0520b8c6eb9a943f934d95fd49cfa (patch)
tree14bf47e72884c999606428c463ec1f6ddff22bdd /src
parent11ae678b9d9b3ea60c3c210cdb129d7abe7d4471 (diff)
macOS: in password lineedits, pass dead keys to the input method
Otherwise the IM cannot correctly compose the input, making it impossible to enter e.g. ü or ~ on certain keyboard layouts. Note that the native macOS NSSecureTextField does not allow that either, which is however a very bad user experience. With this change, the modifier characters like ¨ diacritics will be visible when entering them in either NoEcho or Password line edits. The follow-up commit will remove those as well. Fixes: QTBUG-84664 Change-Id: Ib4c5ab85634c17c407623f82b46c4849c72d9e69 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm2
-rw-r--r--src/plugins/platforms/cocoa/qnsview_keys.mm6
2 files changed, 7 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 471fa368c3..8e4efc6fb6 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -125,6 +125,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSViewMouseMoveHelper);
Qt::MouseButtons m_frameStrutButtons;
QString m_composingText;
QPointer<QObject> m_composingFocusObject;
+ bool m_lastKeyDead;
bool m_sendKeyEvent;
bool m_dontOverrideCtrlLMB;
bool m_sendUpAsRightButton;
@@ -142,6 +143,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSViewMouseMoveHelper);
{
if ((self = [super initWithFrame:NSZeroRect])) {
m_platformWindow = platformWindow;
+ m_lastKeyDead = false;
m_sendKeyEvent = false;
m_inputSource = nil;
m_resendKeyEvent = false;
diff --git a/src/plugins/platforms/cocoa/qnsview_keys.mm b/src/plugins/platforms/cocoa/qnsview_keys.mm
index 23b8254d63..d58155237e 100644
--- a/src/plugins/platforms/cocoa/qnsview_keys.mm
+++ b/src/plugins/platforms/cocoa/qnsview_keys.mm
@@ -111,11 +111,15 @@
if (QCoreApplication::sendEvent(fo, &queryEvent)) {
bool imEnabled = queryEvent.value(Qt::ImEnabled).toBool();
Qt::InputMethodHints hints = static_cast<Qt::InputMethodHints>(queryEvent.value(Qt::ImHints).toUInt());
- if (imEnabled && !(hints & Qt::ImhDigitsOnly || hints & Qt::ImhFormattedNumbersOnly || hints & Qt::ImhHiddenText)) {
+ // make sure we send dead keys and the next key to the input method for composition
+ const bool ignoreHidden = (hints & Qt::ImhHiddenText) && !text.isEmpty() && !m_lastKeyDead;
+ if (imEnabled && !(hints & Qt::ImhDigitsOnly || hints & Qt::ImhFormattedNumbersOnly || ignoreHidden)) {
// pass the key event to the input method. note that m_sendKeyEvent may be set to false during this call
m_currentlyInterpretedKeyEvent = nsevent;
[self interpretKeyEvents:@[nsevent]];
m_currentlyInterpretedKeyEvent = 0;
+ // if the last key we sent was dead, then pass the next key to the IM as well to complete composition
+ m_lastKeyDead = text.isEmpty();
}
}
}