Commit 2e61be73 authored by Antony Lee's avatar Antony Lee
Browse files

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.
parent 1e821049
......@@ -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
\ No newline at end of file
Markdown is supported
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