Skip to content

Commit

Permalink
ENH: ignore all middle-click mouse relase events
Browse files Browse the repository at this point in the history
Do this to avoid middle-click pasting clipboard contents into
PyDMLineEdits. This seems like cleaner way to do it than before.
  • Loading branch information
nstelter-slac committed May 7, 2024
1 parent aa4e2df commit 0e55680
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions pydm/widgets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 0e55680

Please sign in to comment.