From b64980d2a8bb6d8cda2706367b242d0de69f7008 Mon Sep 17 00:00:00 2001 From: Murray Stevenson <50844517+murraystevenson@users.noreply.github.com> Date: Wed, 30 Apr 2025 14:36:24 -0700 Subject: [PATCH] MultiLineTextWidget : Clear selection on focus loss Otherwise the text selection highlight lingers and is only cleared once focus is returned to the widget. We don't clear selection for events with a reason of `QtCore.Qt.PopupFocusReason` to ensure selection is maintained while focus is lost to a popup menu. --- Changes.md | 1 + python/GafferUI/MultiLineTextWidget.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Changes.md b/Changes.md index 8618d1306c5..438c0d73876 100644 --- a/Changes.md +++ b/Changes.md @@ -5,6 +5,7 @@ Fixes ----- - RenderMan : Fixed handling of `render:{name}` attributes, such as the `render:displayColor` attribute created by StandardAttributes, and `primvar:{name}` attributes loaded from USD files. These can now be accessed by PxrAttribute shaders as either `user:{name}` or just `{name}`. +- MultiLineTextWidget : Fixed bug causing text selection highlighting to persist after the widget has lost focus. 1.5.12.0 (relative to 1.5.11.0) ======== diff --git a/python/GafferUI/MultiLineTextWidget.py b/python/GafferUI/MultiLineTextWidget.py index 1a7e316ec85..81275f5d407 100644 --- a/python/GafferUI/MultiLineTextWidget.py +++ b/python/GafferUI/MultiLineTextWidget.py @@ -587,6 +587,11 @@ def focusOutEvent( self, event ) : if widget is not None : widget._emitEditingFinished() + if event.reason() != QtCore.Qt.PopupFocusReason : + cursor = self.textCursor() + cursor.clearSelection() + self.setTextCursor( cursor ) + QtWidgets.QPlainTextEdit.focusOutEvent( self, event ) def paintEvent( self, event ) :