diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2021-02-02 16:24:58 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-02-04 15:26:26 +0000 |
commit | afa1c138c5a9f745358ea4c9885ce6292e61299a (patch) | |
tree | 0bfd0057d97e4b16d07d591ede27e229b93eb56d | |
parent | e6dc083aa9e2bafde751e8779a61bb84d4fc9d79 (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.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index 8a9827a0be..daa92d8d20 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -3494,11 +3494,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); |