Also pass along mouse events for panning

This commit is contained in:
herodotus77 2021-10-08 21:04:12 -07:00
parent 09ac6233aa
commit e06a4657ad
3 changed files with 7 additions and 5 deletions

View File

@ -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

View File

@ -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):

View File

@ -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: