aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-02-02 16:24:58 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-30 20:55:03 +0000
commit4a8942cc1fbd168949bc2b4f2d83a326eaeca8d9 (patch)
treee68cd2a57fa7c8dc91d9a34b26d07e1b17ae102a
parenta80ce81b5fe7befde34e4fbab91e09013288f284 (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. Fixes: QTBUG-72757 Change-Id: Ic39c60fbce982f80d014befddbb2d4439ddeea4f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> (cherry picked from commit 04c0615352e947a23bcd52a0da4f901b3decdb87) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-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 419ac4a2bb..8d33b68413 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -3503,11 +3503,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);