TextInput: Update text deselection on focus out event
authorCaroline Chao <caroline.chao@digia.com>
Tue, 5 Mar 2013 10:11:02 +0000 (11:11 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 7 Mar 2013 10:58:50 +0000 (11:58 +0100)
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 <frederik.gladhorn@digia.com>
src/quick/items/qquicktextinput.cpp

index 67664ad..58cc684 100644 (file)
@@ -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