From 1735effea73d051c3155e6d261cf0c3f778f303f Mon Sep 17 00:00:00 2001 From: Martin Chase Date: Wed, 26 May 2021 17:14:08 -0700 Subject: [PATCH] fix click bug on removable ROIs; test (#1804) --- pyqtgraph/graphicsItems/ROI.py | 2 +- pyqtgraph/graphicsItems/tests/test_ROI.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/graphicsItems/ROI.py b/pyqtgraph/graphicsItems/ROI.py index b6e74095..d9843167 100644 --- a/pyqtgraph/graphicsItems/ROI.py +++ b/pyqtgraph/graphicsItems/ROI.py @@ -801,7 +801,7 @@ class ROI(GraphicsObject): if ev.button() == QtCore.Qt.RightButton and self.contextMenuEnabled(): self.raiseContextMenu(ev) ev.accept() - elif ev.button() in self.acceptedMouseButtons(): + elif ev.button() & self.acceptedMouseButtons() > 0: ev.accept() self.sigClicked.emit(self, ev) else: diff --git a/pyqtgraph/graphicsItems/tests/test_ROI.py b/pyqtgraph/graphicsItems/tests/test_ROI.py index 7005adfa..044c178b 100644 --- a/pyqtgraph/graphicsItems/tests/test_ROI.py +++ b/pyqtgraph/graphicsItems/tests/test_ROI.py @@ -153,6 +153,24 @@ def check_getArrayRegion(roi, name, testResize=True, transpose=False): win.hide() + +def test_mouseClickEvent(): + plt = pg.GraphicsView() + plt.show() + resizeWindow(plt, 200, 200) + vb = pg.ViewBox() + plt.scene().addItem(vb) + vb.resize(200, 200) + QtTest.QTest.qWaitForWindowExposed(plt) + QtTest.QTest.qWait(100) + + roi = pg.RectROI((0, 0), (10, 20), removable=True) + vb.addItem(roi) + app.processEvents() + + mouseClick(plt, roi.mapToScene(pg.Point(2, 2)), QtCore.Qt.LeftButton) + + def test_PolyLineROI(): rois = [ (pg.PolyLineROI([[0, 0], [10, 0], [0, 15]], closed=True, pen=0.3), 'closed'),