aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-02-02 16:24:58 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-02-04 14:47:39 +0100
commit04c0615352e947a23bcd52a0da4f901b3decdb87 (patch)
treeb5b3b319860325fa638733ef06bf8b0499d8be69 /src
parent6da66ff611902d8c4d485568d746f49c69f1330f (diff)
qquicktextinput: ensure we update IM when cursor changes position
Normally the cursor will change position inside a text input after receiving a touch or a keypress event. But it can also change position by sending it a QInputMethodEvent. But as it stood, we would in that case not inform the platform input context about it, which meant that the IM state in QQuickTextInput would be different from the IM state in QPA. A bug on iOS could be seen from this when dragging the cursor around using the magnifier glass. In that case QIOSTextResponder would move the cursor in QQuickTextInput using QInputMethodEvents. But since this would not be forwarded back to UITextInput, the result would be that if you e.g pushed backspace on the input panel, you would delete the character at the position the cursor had before the drag. This patch will ensure that we update platform IM state whenever the cursor changes position from QInputMethodEvents. Pick-to: 6.0 5.15 Fixes: QTBUG-72757 Change-Id: Ic39c60fbce982f80d014befddbb2d4439ddeea4f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquicktextinput.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index d599ff4552..dd581c56be 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -3497,11 +3497,10 @@ void QQuickTextInputPrivate::processInputMethodEvent(QInputMethodEvent *event)
m_textLayout.setFormats(formats);
updateDisplayText(/*force*/ true);
- if ((cursorPositionChanged && !emitCursorPositionChanged())
- || m_preeditCursor != oldPreeditCursor
- || isGettingInput) {
+ if (cursorPositionChanged && emitCursorPositionChanged())
+ q->updateInputMethod(Qt::ImCursorPosition | Qt::ImAnchorPosition);
+ else if (m_preeditCursor != oldPreeditCursor || isGettingInput)
q->updateCursorRectangle();
- }
if (isGettingInput)
finishChange(priorState);