     override func mouseDragged(theEvent: NSEvent) {
         if let activeHandle = activeHandle {
             let location = self.convertPoint(theEvent.locationInWindow, fromView:nil)
-            self.editor.setHandlePosition(activeHandle, position:location)
+            activeCurve!.setHandlePosition(activeHandle, position:location)
             self.needsDisplay = true
         }
     }
 
     override func mouseUp(theEvent: NSEvent) {
+        self.activeCurve = nil
         self.activeHandle = nil
         self.needsDisplay = true
     }
 
-    func handleHit(point:CGPoint) -> Int? {
-        for (index, handle) in enumerate(self.editor.handles) {
-            let R = CGFloat(10.0)
-            let handleRect = CGRect(x:handle.position.x - R, y:handle.position.y - R, width:R * 2, height:R * 2)
-            if handleRect.contains(point) {
-                return index
+    func handleHit(point:CGPoint) -> (Editor, Int)? {
+        for curve in self.curves {
+            for (index, handle) in enumerate(curve.handles) {
+                let R = CGFloat(10.0)
+                let handleRect = CGRect(x:handle.position.x - R, y:handle.position.y - R, width:R * 2, height:R * 2)
+                if handleRect.contains(point) {
+                    return (curve, index)
+                }
             }
         }
         return nil

    var handles:[Handle] = []
    var guides:[Handle] = []

    init() {
        self.curve = BezierCurve(start:CGPoint(x:100,y:100), control1:CGPoint(x:150,y:150), end:CGPoint(x:200,y:100))
        self.handles = self.curve.points.map {
            (p:CGPoint) -> Handle in
            return Handle(position:p)
            }    
        self._update()
    }
    

        context.stroke(self.curve)
        context.withColor(CGColor.lightGrayColor()) {
            context.strokeRect(self.curve.bounds)
            let points = self.curve.points
            context.strokeLine(points[0], points[1])
            context.strokeLine(points[2], self.curve.end)
        }
    }
}

class EditorView: NSView {

    var curves : [Editor] = [
        BezierEditor(BezierCurve(start:CGPoint(x:100,y:200), control1:CGPoint(x:150,y:250),
            control2:CGPoint(x:200,y:250), end:CGPoint(x:200,y:200))),
        BezierEditor(BezierCurve(start:CGPoint(x:100,y:100), control1:CGPoint(x:150,y:150),
            end:CGPoint(x:200,y:100)))]
    
    var activeCurve : Editor?
    var activeHandle : Int?

//    override init(frame frameRect: NSRect) {
