Don't copy the context menu of ViewBoxes.
This allows customization of the context menu of a ViewBox simply by calling viewbox.menu.addAction(...). See issue #13. Also some cleanup.
This commit is contained in:
parent
1e82104986
commit
2e61be739f
@ -1054,26 +1054,15 @@ class ViewBox(GraphicsWidget):
|
||||
if ev.button() == QtCore.Qt.RightButton and self.menuEnabled():
|
||||
ev.accept()
|
||||
self.raiseContextMenu(ev)
|
||||
|
||||
|
||||
def raiseContextMenu(self, ev):
|
||||
#print "viewbox.raiseContextMenu called."
|
||||
|
||||
#menu = self.getMenu(ev)
|
||||
menu = self.getMenu(ev)
|
||||
self.scene().addParentContextMenus(self, menu, ev)
|
||||
#print "2:", [str(a.text()) for a in self.menu.actions()]
|
||||
pos = ev.screenPos()
|
||||
#pos2 = ev.scenePos()
|
||||
#print "3:", [str(a.text()) for a in self.menu.actions()]
|
||||
#self.sigActionPositionChanged.emit(pos2)
|
||||
menu.popup(ev.screenPos().toPoint())
|
||||
|
||||
menu.popup(QtCore.QPoint(pos.x(), pos.y()))
|
||||
#print "4:", [str(a.text()) for a in self.menu.actions()]
|
||||
|
||||
def getMenu(self, ev):
|
||||
self._menuCopy = self.menu.copy() ## temporary storage to prevent menu disappearing
|
||||
return self._menuCopy
|
||||
|
||||
return self.menu
|
||||
|
||||
def getContextMenus(self, event):
|
||||
if self.menuEnabled():
|
||||
return self.menu.subMenus()
|
||||
|
@ -275,4 +275,4 @@ class ViewBoxMenu(QtGui.QMenu):
|
||||
|
||||
from .ViewBox import ViewBox
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user