Make editors commit preedit themselves on losing focus

Change-Id: I1d42a8804068718c7347b4f652289f9724c25a3c
Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
This commit is contained in:
Pekka Vuorela 2011-12-05 17:03:18 +02:00 committed by Qt by Nokia
parent a231d3c67a
commit 9697e2af14
3 changed files with 9 additions and 4 deletions

View File

@ -1065,8 +1065,10 @@ void QDeclarative1TextInputPrivate::focusChanged(bool hasFocus)
q->setCursorVisible(hasFocus && scene && scene->hasFocus());
if(!hasFocus && control->passwordEchoEditing())
control->updatePasswordEchoEditing(false);//QWidgetLineControl sets it on key events, but doesn't deal with focus events
if (!hasFocus)
if (!hasFocus) {
control->commitPreedit();
control->deselect();
}
QDeclarativeItemPrivate::focusChanged(hasFocus);
}

View File

@ -383,7 +383,7 @@ void QQuickCanvasPrivate::setFocusInScope(QQuickItem *scope, QQuickItem *item, F
if (oldActiveFocusItem) {
#ifndef QT_NO_IM
qApp->inputPanel()->commit();
qApp->inputPanel()->reset();
#endif
activeFocusItem = 0;
@ -492,7 +492,7 @@ void QQuickCanvasPrivate::clearFocusInScope(QQuickItem *scope, QQuickItem *item,
Q_ASSERT(oldActiveFocusItem);
#ifndef QT_NO_IM
qApp->inputPanel()->commit();
qApp->inputPanel()->reset();
#endif
activeFocusItem = 0;

View File

@ -2004,8 +2004,11 @@ void QQuickTextInput::itemChange(ItemChange change, const ItemChangeData &value)
#endif
d->updatePasswordEchoEditing(false);//QQuickTextInputPrivate sets it on key events, but doesn't deal with focus events
}
if (!hasFocus)
if (!hasFocus) {
d->commitPreedit();
d->deselect();
}
}
QQuickItem::itemChange(change, value);
}