From da678e141dd79422a799f89ef6bae4fa43a28b4b Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Tue, 20 Jan 2009 17:29:18 +0000 Subject: Don't accept drags outside the canvas --- 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) -- cgit v0.9.1