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>
This commit is contained in:
parent
a3d6a04949
commit
fc9baeeb9f
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user