Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-01-20 17:29:18 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-01-20 17:29:18 (GMT)
commitda678e141dd79422a799f89ef6bae4fa43a28b4b (patch)
treeb8b4729b9a18325ff9b21c3fb4788bbabd9490ef
parentb3e2037e6b04890c427d5b69fa1bc6e265410c87 (diff)
Don't accept drags outside the canvas
-rw-r--r--view.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/view.py b/view.py
index 66e29c7..8ba64ea 100644
--- a/view.py
+++ b/view.py
@@ -53,8 +53,13 @@ class MindMapView(Canvas):
thought = kwargs['element']
logging.debug('__dragging_finished_cb %r %r' % (x, y))
thought.dragging = False
- thought.model.x = x
- thought.model.y = y
+
+ rect = self.get_allocation()
+ thought_rect = thought.get_rect()
+ if (x >= 0 and x + thought_rect.width <= rect.width) and \
+ (y >= 0 and y + thought_rect.height <= rect.height):
+ thought.model.x = x
+ thought.model.y = y
def set_model(self, new_model):
logging.debug('set_model %r' % new_model)