From 9bfdda06a63bdbcaf66cf022517b32a3f86bbb3f Mon Sep 17 00:00:00 2001 From: HashSplat Date: Wed, 20 Sep 2017 17:15:54 -0400 Subject: [PATCH 1/2] Fixed AxisMouse drag issue Issue where MouseDragEvent would only work for 1 AxisItem. Allowed the MouseDragEvent to propagate to other AxisItems. I had this issue by setting the ViewBox background color and changed the AxisItem ZValue to make the AxisItems visible which made the AxisItem receive all of the MouseDragEvents and only one Axis would actually allow dragging. --- pyqtgraph/graphicsItems/AxisItem.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyqtgraph/graphicsItems/AxisItem.py b/pyqtgraph/graphicsItems/AxisItem.py index b125cb7e..9ba3c614 100644 --- a/pyqtgraph/graphicsItems/AxisItem.py +++ b/pyqtgraph/graphicsItems/AxisItem.py @@ -1066,9 +1066,11 @@ class AxisItem(GraphicsWidget): if self.linkedView() is None: return if self.orientation in ['left', 'right']: - return self.linkedView().mouseDragEvent(event, axis=1) + ret = self.linkedView().mouseDragEvent(event, axis=1) else: - return self.linkedView().mouseDragEvent(event, axis=0) + ret = self.linkedView().mouseDragEvent(event, axis=0) + event.ignore() + return ret def mouseClickEvent(self, event): if self.linkedView() is None: From 6b26245e506e9c7140f1acad204a5490ef9dff26 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Fri, 28 Sep 2018 16:02:14 -0700 Subject: [PATCH 2/2] Add explanatory comment --- pyqtgraph/graphicsItems/AxisItem.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyqtgraph/graphicsItems/AxisItem.py b/pyqtgraph/graphicsItems/AxisItem.py index 9ba3c614..a50c75a1 100644 --- a/pyqtgraph/graphicsItems/AxisItem.py +++ b/pyqtgraph/graphicsItems/AxisItem.py @@ -1069,6 +1069,10 @@ class AxisItem(GraphicsWidget): ret = self.linkedView().mouseDragEvent(event, axis=1) else: ret = self.linkedView().mouseDragEvent(event, axis=0) + # Ignore event because if grid lines are enabled, we don't want the + # AxisItem to eat events meant for the ViewBox (see PR #565). A better + # solution here is to have grid lines drawn by a separate item inside the + # viewbox. event.ignore() return ret