From c27b521933b080c77e5cb7fa3cb5b7b011418263 Mon Sep 17 00:00:00 2001 From: nstelter Date: Mon, 2 Oct 2023 00:18:23 -0700 Subject: [PATCH] BUG: Only override middle-click release when widget has an connected channel This way we prevent the automatic-pasting of middle-click clipboard into PyDMLineEdits, but still allow pasting with middle-click into other edits used for entering text. --- pydm/widgets/base.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pydm/widgets/base.py b/pydm/widgets/base.py index aec4b3209..6d3c7e79c 100644 --- a/pydm/widgets/base.py +++ b/pydm/widgets/base.py @@ -190,11 +190,21 @@ def eventFilter(self, obj, event): # from getting paste into PyDMLineEdits, since paste happens at mouse release. if event.type() == QEvent.MouseButtonRelease: if event.button() == Qt.MiddleButton: - self.show_address_tooltip(event) - return True + channels_method = getattr(self, "channels", None) + if channels_method is None: + return + channels = channels_method() + if channels: + self.show_address_tooltip(event, channels) + return True + else: + # return and run default behavior middle-click paste if PyDMLineEdit + # is not connected to channel, so you can still paste the middle-click + # clipboard into edits intended for text entry. + return False return False - def show_address_tooltip(self, event): + def show_address_tooltip(self, event, channels): """ Show the PyDMTooltip and copy address to clipboard