From 0e55680c1adf68a1615bb8445c755ef9fe5eec10 Mon Sep 17 00:00:00 2001 From: nstelter Date: Mon, 6 May 2024 17:53:44 -0700 Subject: [PATCH] ENH: ignore all middle-click mouse relase events Do this to avoid middle-click pasting clipboard contents into PyDMLineEdits. This seems like cleaner way to do it than before. --- pydm/widgets/base.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/pydm/widgets/base.py b/pydm/widgets/base.py index 5971912d6..311b9a647 100644 --- a/pydm/widgets/base.py +++ b/pydm/widgets/base.py @@ -186,22 +186,15 @@ def eventFilter(self, obj, event): """ # Override the eventFilter to capture all middle mouse button events, # and show a tooltip if needed. - # We capture the release event (instead of press event) to prevent clipboard contents - # from getting paste into PyDMLineEdits, since paste happens at mouse release. + if event.type() == QEvent.MouseButtonPress: + if event.button() == Qt.MiddleButton: + self.show_address_tooltip(event) + return True if event.type() == QEvent.MouseButtonRelease: if event.button() == Qt.MiddleButton: - channels_method = getattr(self, "channels", None) - if channels_method is None: - return - channels = channels_method() - if channels: - self.show_address_tooltip(event) - 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 + event.ignore() + return True + return False def show_address_tooltip(self, event):