From e06a4657ad82c3479c05de79344ca67ddfd15508 Mon Sep 17 00:00:00 2001 From: herodotus77 Date: Fri, 8 Oct 2021 21:04:12 -0700 Subject: [PATCH] Also pass along mouse events for panning --- examples/MultiplePlotAxes.py | 2 +- pyqtgraph/graphicsItems/PlotItem/PlotItem.py | 3 +-- pyqtgraph/graphicsItems/ViewBox/ViewBox.py | 7 +++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/MultiplePlotAxes.py b/examples/MultiplePlotAxes.py index d5da4052..8d573c91 100644 --- a/examples/MultiplePlotAxes.py +++ b/examples/MultiplePlotAxes.py @@ -2,7 +2,7 @@ """ Demonstrates a way to put multiple axes around a single plot. """ -import initExample ## Add path to library (just for examples; you do not need this) +import initExample ## Add path to library (just for examples; you do not need this) import pyqtgraph as pg diff --git a/pyqtgraph/graphicsItems/PlotItem/PlotItem.py b/pyqtgraph/graphicsItems/PlotItem/PlotItem.py index ed77ab42..7109f45a 100644 --- a/pyqtgraph/graphicsItems/PlotItem/PlotItem.py +++ b/pyqtgraph/graphicsItems/PlotItem/PlotItem.py @@ -390,7 +390,7 @@ class PlotItem(GraphicsWidget): self.stackedViews.add(view) # These signals will be emitted by the top level view when it handles these events - self.vb.sigMouseDragZoomed.connect(view.mouseDragEvent) + self.vb.sigMouseDragged.connect(view.mouseDragEvent) self.vb.sigMouseWheelZoomed.connect(view.wheelEvent) self.vb.sigHistoryChanged.connect(view.scaleHistory) @@ -758,7 +758,6 @@ class PlotItem(GraphicsWidget): layout. See removeItem(), clearPlots(), or clear() if removing the items themselves is required. """ while self.layout.count() > 0: - item = self.layout.itemAt(0) self.layout.removeAt(0) def rebuildLayout(self): diff --git a/pyqtgraph/graphicsItems/ViewBox/ViewBox.py b/pyqtgraph/graphicsItems/ViewBox/ViewBox.py index 8f619e0a..568b8fdd 100644 --- a/pyqtgraph/graphicsItems/ViewBox/ViewBox.py +++ b/pyqtgraph/graphicsItems/ViewBox/ViewBox.py @@ -94,7 +94,7 @@ class ViewBox(GraphicsWidget): sigStateChanged = QtCore.Signal(object) sigTransformChanged = QtCore.Signal(object) sigResized = QtCore.Signal(object) - sigMouseDragZoomed = QtCore.Signal(object, object) + sigMouseDragged = QtCore.Signal(object, object) sigMouseWheelZoomed = QtCore.Signal(object, object) sigHistoryChanged = QtCore.Signal(object) @@ -1264,7 +1264,7 @@ class ViewBox(GraphicsWidget): self.rbScaleBox.hide() ax = QtCore.QRectF(Point(ev.buttonDownPos(ev.button())), Point(pos)) ax = self.childGroup.mapRectFromParent(ax) - self.sigMouseDragZoomed.emit(ev, axis) + self.sigMouseDragged.emit(ev, axis) self.showAxRect(ax) self.axHistoryPointer += 1 self.axHistory = self.axHistory[:self.axHistoryPointer] + [ax] @@ -1283,6 +1283,9 @@ class ViewBox(GraphicsWidget): if x is not None or y is not None: self.translateBy(x=x, y=y) self.sigRangeChangedManually.emit(self.state['mouseEnabled']) + if axis is None: + # This event happened directly in the view box, so propagate to any stacked views + self.sigMouseDragged.emit(ev, axis) elif ev.button() & QtCore.Qt.MouseButton.RightButton: #print "vb.rightDrag" if self.state['aspectLocked'] is not False: