Skip to content

Commit 0e55680

Browse files
committed
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.
1 parent aa4e2df commit 0e55680

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

pydm/widgets/base.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,15 @@ def eventFilter(self, obj, event):
186186
"""
187187
# Override the eventFilter to capture all middle mouse button events,
188188
# and show a tooltip if needed.
189-
# We capture the release event (instead of press event) to prevent clipboard contents
190-
# from getting paste into PyDMLineEdits, since paste happens at mouse release.
189+
if event.type() == QEvent.MouseButtonPress:
190+
if event.button() == Qt.MiddleButton:
191+
self.show_address_tooltip(event)
192+
return True
191193
if event.type() == QEvent.MouseButtonRelease:
192194
if event.button() == Qt.MiddleButton:
193-
channels_method = getattr(self, "channels", None)
194-
if channels_method is None:
195-
return
196-
channels = channels_method()
197-
if channels:
198-
self.show_address_tooltip(event)
199-
return True
200-
else:
201-
# return and run default behavior middle-click paste if PyDMLineEdit
202-
# is not connected to channel, so you can still paste the middle-click
203-
# clipboard into edits intended for text entry.
204-
return False
195+
event.ignore()
196+
return True
197+
205198
return False
206199

207200
def show_address_tooltip(self, event):

0 commit comments

Comments
 (0)