         }
     }
     
+    // MARK: - Actions
+    
+    override public func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
+        touchesMoved = false
+        if let touch = touches.first {
+            lastPoint = touch.locationInView(self)
+            pointsArray = []
+            pointsArray.addObject(NSStringFromCGPoint(lastPoint))
+        }
+    }
+    
+    override public func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
+        touchesMoved = true
+        if let touch = touches.first {
+            let currentPoint = touch.locationInView(self)
+            drawLineFrom(lastPoint, toPoint: currentPoint, properties: brushProperties)
+            
+            lastPoint = currentPoint
+            pointsArray.addObject(NSStringFromCGPoint(lastPoint))
+        }
+    }
+    
+    override public func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
+        if !touchesMoved {
+            // draw a single point
+            drawLineFrom(lastPoint, toPoint: lastPoint, properties: brushProperties)
+        }
+        
+        mergeViews()
+        
+        let stroke = Stroke()
+        stroke.properties = BrushProperties(properties: brushProperties)
+        stroke.points = pointsArray
+        
+        stack.append(stroke)
+        
+        undoManager?.registerUndoWithTarget(self, selector: "popDrawing", object: nil)
+        
+        if !undoEnabled {
+            delegate.undoEnabled()
+            undoEnabled = true
+        }
+        if redoEnabled {
+            delegate.redoDisabled()
+            redoEnabled = false
+        }
+        if !clearEnabled {
+            self.delegate.clearEnabled()
+            clearEnabled = true
+        }
+    }
 }

    private var redoEnabled = false
    private var clearEnabled = false
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        initTouchDrawView()
    }

    required public init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        initTouchDrawView()

    override public func drawRect(rect: CGRect) {
        mainImageView.frame = rect
        tempImageView.frame = rect
    }
    
    private func mergeViews() {
