From 04592dae5067b87b39e1ae9387e522fb394159d6 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 5 Mar 2013 11:11:02 +0100 Subject: [PATCH] TextInput: Update text deselection on focus out event The text selection should not be cleared when the focus out event received has one the following reasons: - Qt::ActiveWindowFocusReason - Qt::PopupFocusReason When the user opens a menu or navigates to another window, the eventual selection should not be clearer. This also makes the behavior consistent with TextEdit. Change-Id: Ibc6242cb2f8207cf5281925c8e20b88394f21eea Reviewed-by: Frederik Gladhorn --- src/quick/items/qquicktextinput.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index 67664ad..58cc684 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -2500,7 +2500,10 @@ void QQuickTextInputPrivate::handleFocusEvent(QFocusEvent *event) updatePasswordEchoEditing(false);//QQuickTextInputPrivate sets it on key events, but doesn't deal with focus events } - if (!persistentSelection) + if (event->reason() != Qt::ActiveWindowFocusReason + && event->reason() != Qt::PopupFocusReason + && hasSelectedText() + && !persistentSelection) deselect(); #ifndef QT_NO_IM -- 2.7.4