add flag for allowing out of scene events

This commit is contained in:
Martin Baeuml
2011-05-13 16:55:49 +02:00
parent d133981a87
commit bb26b01057
2 changed files with 8 additions and 4 deletions
+5 -4
View File
@@ -137,10 +137,11 @@ class AnnotationScene(QGraphicsScene):
def mousePressEvent(self, event):
if self.debug_:
print "mousePressEvent", self.sceneRect().contains(event.scenePos()), event.scenePos()
if not self.sceneRect().contains(event.scenePos()):
# ignore events outside the scene rect
return
elif self.inserter_ is not None:
if self.inserter_ is not None:
if not self.sceneRect().contains(event.scenePos()) and \
not self.inserter_.allowOutOfSceneEvents():
# ignore events outside the scene rect
return
# insert mode
self.inserter_.mousePressEvent(event, self.root_)
else:
+3
View File
@@ -29,6 +29,9 @@ class ItemInserter:
def keyPressEvent(self, event, index):
event.ignore()
def allowOutOfSceneEvents(self):
return False
class PointItemInserter(ItemInserter):
def mousePressEvent(self, event, index):
pos = event.scenePos()