diff options
author | Vova Mshanetskiy <vovams163@gmail.com> | 2019-04-25 17:02:44 +0300 |
---|---|---|
committer | Vova Mshanetskiy <vovams163@gmail.com> | 2019-05-07 10:49:12 +0000 |
commit | fc9baeeb9f6360051cb02d1da6c094aa8154f58e (patch) | |
tree | 871d49096dcb00b63594fb9c5a2c8cd421aa88bd /src/widgets/widgets/qwidgettextcontrol.cpp | |
parent | a3d6a049490d78cb3149de490a9e1ff494a2ce52 (diff) |
QWidgetTextControl: Emit cursorPositionChanged() when handling IM event
QWidgetTextControl and consequently QTextEdit did not emit
cursorPositionChanged() signal when cursor position was changed by a
QInputMethodEvent with a QInputMethodEvent::Selection attribute.
This is especially important on Android because QAndroidInputContext
uses such events extensively to move the cursor and also relies on
cursorPositionChanged() signal being emitted by the focus object. If the
signal is not emitted, QAndroidInputContext does not notify the virtual
keyboard about cursor position change which results in various glitches.
Change-Id: I7edd141258c483e6f103adcd6e40049b49c13387
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/widgets/qwidgettextcontrol.cpp')
-rw-r--r-- | src/widgets/widgets/qwidgettextcontrol.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index e179ea3b40..6b8ce63380 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1974,6 +1974,8 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) || e->preeditString() != cursor.block().layout()->preeditAreaText() || e->replacementLength() > 0; + int oldCursorPos = cursor.position(); + cursor.beginEditBlock(); if (isGettingInput) { cursor.removeSelectedText(); @@ -2078,6 +2080,8 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) if (cursor.d) cursor.d->setX(); + if (oldCursorPos != cursor.position()) + emit q->cursorPositionChanged(); if (oldPreeditCursor != preeditCursor) emit q->microFocusChanged(); } |