diff options
author | Tomeu Vizoso <tomeu@sugarlabs.org> | 2009-01-20 17:29:18 (GMT) |
---|---|---|
committer | Tomeu Vizoso <tomeu@sugarlabs.org> | 2009-01-20 17:29:18 (GMT) |
commit | da678e141dd79422a799f89ef6bae4fa43a28b4b (patch) | |
tree | b8b4729b9a18325ff9b21c3fb4788bbabd9490ef | |
parent | b3e2037e6b04890c427d5b69fa1bc6e265410c87 (diff) |
Don't accept drags outside the canvas
-rw-r--r-- | view.py | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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) |