diff --git a/SketchWidget.py b/SketchWidget.py index cf20895..4e6d923 100644 --- a/SketchWidget.py +++ b/SketchWidget.py @@ -367,8 +367,7 @@ class SketchWidget: else: self.widget.window.set_cursor(self.cursors['arrow']) self.mode = mode - self.drawingShape = None - self.drawingConstraints = [] + self.cancel_drawing_shape() def do_line_left_click(self, x, y): start = self.screenPtToPt((x, self.size[1] - y)) @@ -380,8 +379,7 @@ class SketchWidget: def do_line_right_click(self, x, y): if self.drawingShape is not None: - # cancel line currently being drawn - self.drawingShape = None + self.cancel_drawing_shape() self.queue_redraw() def do_line_motion(self, x, y): @@ -421,8 +419,7 @@ class SketchWidget: def do_circle_right_click(self, x, y): if self.drawingShape is not None: - # cancel circle currently being drawn - self.drawingShape = None + self.cancel_drawing_shape() self.queue_redraw() def do_circle_motion(self, x, y): @@ -431,6 +428,10 @@ class SketchWidget: self.drawingShape.setRadius(r) self.queue_redraw() + def cancel_drawing_shape(self): + self.drawingShape = None + self.drawingConstraints = [] + def merge_in_drawing_shape(self): self.sketch.shapes.append(self.drawingShape) for c in self.drawingConstraints: