Skip to content

Commit

Permalink
BUG: Only override middle-click release when widget has an connected …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
nstelter-slac committed May 7, 2024
1 parent d7eceb1 commit bea8db4
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pydm/widgets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bea8db4

Please sign in to comment.