From 1d0f808c7dc708f5ec8093f09f332615b94f4318 Mon Sep 17 00:00:00 2001 From: Nils Jeisecke Date: Wed, 13 Feb 2019 15:28:11 +0100 Subject: TextEdit: Fix persistentSelection for readonly controls TextEdit items with readOnly:true do not clear the selection on losing focus which is expected with persistentSelection:false. The reason is that a readonly TextEdit does never show a blinking cursor and thus the selection clearing within setCursorVisible never happens. This change adapts the implementation from TextInput. Fixes: QTBUG-50587 Change-Id: Ie66baaa0ccbc006359473862d8e9dbecd46a59f6 Reviewed-by: Shawn Rutledge Reviewed-by: Mitch Curtis --- src/quick/items/qquicktextedit.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/quick/items/qquicktextedit.cpp') diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index 3a12ad6ba5..6b4b118eb7 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -2689,6 +2689,12 @@ void QQuickTextEditPrivate::handleFocusEvent(QFocusEvent *event) q->disconnect(QGuiApplication::inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)), q, SLOT(q_updateAlignment())); #endif + if (event->reason() != Qt::ActiveWindowFocusReason + && event->reason() != Qt::PopupFocusReason + && control->textCursor().hasSelection() + && !persistentSelection) + q->deselect(); + emit q->editingFinished(); } } -- cgit v1.2.3