diff options
author | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2021-08-05 10:21:07 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-08-23 14:53:23 +0000 |
commit | ec3c3e03732a94b34cd431dd7adc9dc999ab221d (patch) | |
tree | 5e59d0685b535dac133326d7e9188ee30e6b1668 /src | |
parent | 87cbf885a9ecb8302c0285882c4724f4c5a20bcf (diff) |
qquicktextinput: Clear pre-edit text after input method reset
The QPlatformInputContext::reset() function does not allow any further
input method events to be called. Therefore, clearing the pre-edit text
is the sole responsibility of the text input control.
This change modifies the QQuickTextInputPrivate::resetInputMethod()
function and calls QQuickTextInputPrivate::cancelPreedit() instead of
QInputMethod::reset() directly. The cancelPreedit() function will send
a QInputMethodEvent which clears the IM state (in addition of calling
QInputMethod::reset() function).
Also, rename the QQuickTextInputPrivate::resetInputMethod() function to
cancelInput, since it does not call inputMethod()->reset() directly.
Fixes: QTBUG-95461
Change-Id: I6ab3b9dbe71956af72656e2a25a05d79603b34ea
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Inho Lee <inho.lee@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
(cherry picked from commit b2103e33f490c96d0068d211c6f2d5b540ca407e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquicktextinput.cpp | 12 | ||||
-rw-r--r-- | src/quick/items/qquicktextinput_p_p.h | 2 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index 4f3c7cb141..ba40e8d3c7 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -2104,7 +2104,7 @@ void QQuickTextInput::undo() { Q_D(QQuickTextInput); if (!d->m_readOnly) { - d->resetInputMethod(); + d->cancelInput(); d->internalUndo(); d->finishChange(-1, true); } @@ -2120,7 +2120,7 @@ void QQuickTextInput::redo() { Q_D(QQuickTextInput); if (!d->m_readOnly) { - d->resetInputMethod(); + d->cancelInput(); d->internalRedo(); d->finishChange(); } @@ -2747,11 +2747,13 @@ void QQuickTextInputPrivate::init() m_inputControl = new QInputControl(QInputControl::LineEdit, q); } -void QQuickTextInputPrivate::resetInputMethod() +void QQuickTextInputPrivate::cancelInput() { +#if QT_CONFIG(im) Q_Q(QQuickTextInput); if (!m_readOnly && q->hasActiveFocus() && qGuiApp) - QGuiApplication::inputMethod()->reset(); + cancelPreedit(); +#endif // im } void QQuickTextInput::updateCursorRectangle(bool scroll) @@ -4697,7 +4699,7 @@ void QQuickTextInput::ensureVisible(int position) void QQuickTextInput::clear() { Q_D(QQuickTextInput); - d->resetInputMethod(); + d->cancelInput(); d->clear(); } diff --git a/src/quick/items/qquicktextinput_p_p.h b/src/quick/items/qquicktextinput_p_p.h index b4561556aa..1fecd7f9df 100644 --- a/src/quick/items/qquicktextinput_p_p.h +++ b/src/quick/items/qquicktextinput_p_p.h @@ -173,7 +173,7 @@ public: } void init(); - void resetInputMethod(); + void cancelInput(); void startCreatingCursor(); void ensureVisible(int position, int preeditCursor = 0, int preeditLength = 0); void updateHorizontalScroll(); |