From bb26b010579e6c1180d4d44fb4a699e3e2236468 Mon Sep 17 00:00:00 2001 From: Martin Baeuml Date: Fri, 13 May 2011 16:55:49 +0200 Subject: [PATCH] add flag for allowing out of scene events --- annotationscene.py | 9 +++++---- items/inserters.py | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/annotationscene.py b/annotationscene.py index af669e3..11b7a8b 100644 --- a/annotationscene.py +++ b/annotationscene.py @@ -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: diff --git a/items/inserters.py b/items/inserters.py index bb023ca..a135bd9 100644 --- a/items/inserters.py +++ b/items/inserters.py @@ -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()