diff --git a/examples/customPlot.py b/examples/customPlot.py index c5e05f91..4b9d9ee5 100644 --- a/examples/customPlot.py +++ b/examples/customPlot.py @@ -14,6 +14,7 @@ import time class CustomViewBox(pg.ViewBox): def __init__(self, *args, **kwds): + kwds['enableMenu'] = False pg.ViewBox.__init__(self, *args, **kwds) self.setMouseMode(self.RectMode) @@ -21,12 +22,13 @@ class CustomViewBox(pg.ViewBox): def mouseClickEvent(self, ev): if ev.button() == QtCore.Qt.RightButton: self.autoRange() - - def mouseDragEvent(self, ev): - if ev.button() == QtCore.Qt.RightButton: + + ## reimplement mouseDragEvent to disable continuous axis zoom + def mouseDragEvent(self, ev, axis=None): + if axis is not None and ev.button() == QtCore.Qt.RightButton: ev.ignore() else: - pg.ViewBox.mouseDragEvent(self, ev) + pg.ViewBox.mouseDragEvent(self, ev, axis=axis) app = pg.mkQApp() diff --git a/pyqtgraph/graphicsItems/ViewBox/ViewBox.py b/pyqtgraph/graphicsItems/ViewBox/ViewBox.py index b08757af..7a117db0 100644 --- a/pyqtgraph/graphicsItems/ViewBox/ViewBox.py +++ b/pyqtgraph/graphicsItems/ViewBox/ViewBox.py @@ -1267,7 +1267,7 @@ class ViewBox(GraphicsWidget): ## Scale or translate based on mouse button if ev.button() & (QtCore.Qt.LeftButton | QtCore.Qt.MidButton): - if self.state['mouseMode'] == ViewBox.RectMode: + if self.state['mouseMode'] == ViewBox.RectMode and axis is None: if ev.isFinish(): ## This is the final move in the drag; change the view scale now #print "finish" self.rbScaleBox.hide()