Merge pull request #814 from danielhrisca/enforce_enableMenu
enforce enableMenu in ViewBox
This commit is contained in:
commit
66604593c1
@ -208,7 +208,10 @@ class ViewBox(GraphicsWidget):
|
||||
self.setAspectLocked(lockAspect)
|
||||
|
||||
self.border = fn.mkPen(border)
|
||||
if enableMenu:
|
||||
self.menu = ViewBoxMenu(self)
|
||||
else:
|
||||
self.menu = None
|
||||
|
||||
self.register(name)
|
||||
if name is None:
|
||||
@ -315,6 +318,13 @@ class ViewBox(GraphicsWidget):
|
||||
del state['linkedViews']
|
||||
|
||||
self.state.update(state)
|
||||
|
||||
if self.state['enableMenu'] and self.menu is None:
|
||||
self.menu = ViewBoxMenu(self)
|
||||
self.updateViewLists()
|
||||
else:
|
||||
self.menu = None
|
||||
|
||||
self.updateViewRange()
|
||||
self.sigStateChanged.emit(self)
|
||||
|
||||
@ -368,6 +378,13 @@ class ViewBox(GraphicsWidget):
|
||||
|
||||
def setMenuEnabled(self, enableMenu=True):
|
||||
self.state['enableMenu'] = enableMenu
|
||||
if enableMenu:
|
||||
if self.menu is None:
|
||||
self.menu = ViewBoxMenu(self)
|
||||
self.updateViewLists()
|
||||
else:
|
||||
self.menu.setParent(None)
|
||||
self.menu = None
|
||||
self.sigStateChanged.emit(self)
|
||||
|
||||
def menuEnabled(self):
|
||||
@ -1149,6 +1166,7 @@ class ViewBox(GraphicsWidget):
|
||||
|
||||
def raiseContextMenu(self, ev):
|
||||
menu = self.getMenu(ev)
|
||||
if menu is not None:
|
||||
self.scene().addParentContextMenus(self, menu, ev)
|
||||
menu.popup(ev.screenPos().toPoint())
|
||||
|
||||
@ -1569,6 +1587,7 @@ class ViewBox(GraphicsWidget):
|
||||
if self in nv:
|
||||
nv.remove(self)
|
||||
|
||||
if self.menu is not None:
|
||||
self.menu.setViewList(nv)
|
||||
|
||||
for ax in [0,1]:
|
||||
|
Loading…
Reference in New Issue
Block a user