Commit f9310d64 authored by Luke Campagnola's avatar Luke Campagnola
Browse files

Imported code for disabling ViewBox menus from Ingo

parent 36433708
......@@ -193,6 +193,7 @@ class PlotItem(GraphicsWidget):
'setXRange', 'setYRange', 'setXLink', 'setYLink', 'setAutoPan', 'setAutoVisible',
'setRange', 'autoRange', 'viewRect', 'viewRange', 'setMouseEnabled',
'enableAutoRange', 'disableAutoRange', 'setAspectLocked',
'setMenuEnabled', 'menuEnabled',
'register', 'unregister']: ## NOTE: If you update this list, please update the class docstring as well.
setattr(self, m, getattr(self.vb, m))
......
......@@ -62,7 +62,7 @@ class ViewBox(GraphicsWidget):
NamedViews = weakref.WeakValueDictionary() # name: ViewBox
AllViews = weakref.WeakKeyDictionary() # ViewBox: None
def __init__(self, parent=None, border=None, lockAspect=False, enableMouse=True, invertY=False, name=None):
def __init__(self, parent=None, border=None, lockAspect=False, enableMouse=True, invertY=False, enableMenu = True, name=None):
"""
============= =============================================================
**Arguments**
......@@ -103,6 +103,7 @@ class ViewBox(GraphicsWidget):
'mouseEnabled': [enableMouse, enableMouse],
'mouseMode': ViewBox.PanMode if pyqtgraph.getConfigOption('leftButtonPan') else ViewBox.RectMode,
'enableMenu': enableMenu,
'wheelScaleFactor': -1.0 / 8.0,
}
......@@ -250,6 +251,13 @@ class ViewBox(GraphicsWidget):
def mouseEnabled(self):
return self.state['mouseEnabled'][:]
def setMenuEnabled(self, enableMenu=True):
self.state['enableMenu'] = enableMenu
self.sigStateChanged.emit(self)
def menuEnabled(self):
return self.state.get('enableMenu', True)
def addItem(self, item, ignoreBounds=False):
"""
......@@ -822,7 +830,7 @@ class ViewBox(GraphicsWidget):
def mouseClickEvent(self, ev):
if ev.button() == QtCore.Qt.RightButton:
if ev.button() == QtCore.Qt.RightButton and self.menuEnabled():
ev.accept()
self.raiseContextMenu(ev)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment