Skip to content

Commit a9cd8d1

Browse files
committed
Ignore second mouse press event in case of a double click.
1 parent d3ec31f commit a9cd8d1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Orange/canvas/canvas/items/nodeitem.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
QPainterPathStroker
1818
)
1919
from AnyQt.QtCore import (
20-
Qt, QEvent, QPointF, QRectF, QRect, QSize, QTimer, QPropertyAnimation
20+
Qt, QEvent, QPointF, QRectF, QRect, QSize, QTime, QTimer, QPropertyAnimation
2121
)
2222
from AnyQt.QtCore import pyqtSignal as Signal, pyqtProperty as Property
2323

@@ -799,6 +799,9 @@ def __init__(self, widget_description=None, parent=None, **kwargs):
799799
self.warningItem = None
800800
self.infoItem = None
801801

802+
self.mousePressTime = QTime()
803+
self.mousePressTime.start()
804+
802805
self.__title = ""
803806
self.__processingState = 0
804807
self.__progress = -1
@@ -1241,10 +1244,14 @@ def __updateMessages(self):
12411244
origin = origin + QPointF(rect.width() + spacing, 0)
12421245

12431246
def mousePressEvent(self, event):
1244-
if self.shapeItem.path().contains(event.pos()):
1245-
return super().mousePressEvent(event)
1246-
else:
1247+
if self.mousePressTime.elapsed() < QApplication.doubleClickInterval():
12471248
event.ignore()
1249+
else:
1250+
self.mousePressTime.restart()
1251+
if self.shapeItem.path().contains(event.pos()):
1252+
return super().mousePressEvent(event)
1253+
else:
1254+
event.ignore()
12481255

12491256
def mouseDoubleClickEvent(self, event):
12501257
if self.shapeItem.path().contains(event.pos()):

0 commit comments

Comments
 (0)