title: Dragging the view
body: <p>I have an <code>NSView</code> which I am adding as a sub-view of another <code>NSView</code>. I want to be able to drag the first <code>NSView</code> around the parent view. I have some code that is partially working but there's an issue with the <code>NSView</code> moving in the opposite direction on the Y axis from my mouse drag. (i.e. I drag down, it goes up and the inverse of that). </p>
  
  <p>Here's my code: </p>
  
  <pre class="lang-c prettyprint-override"><code>// -------------------- MOUSE EVENTS ------------------- \\ 
  
  - (BOOL) acceptsFirstMouse:(NSEvent *)e {
      return YES;
  }
  
  - (void)mouseDown:(NSEvent *) e { 
      //get the mouse point
      lastDragLocation = [e locationInWindow];
  }
  
  - (void)mouseDragged:(NSEvent *)theEvent {
      NSPoint newDragLocation = [theEvent locationInWindow];
      NSPoint thisOrigin = [self frame].origin;
      thisOrigin.x += (-lastDragLocation.x + newDragLocation.x);
      thisOrigin.y += (-lastDragLocation.y + newDragLocation.y);
      [self setFrameOrigin:thisOrigin];
      lastDragLocation = newDragLocation;
  }
  </code></pre>
  
  <p>The view is flipped, though I changed that back to the default and it didn't seem to make a difference. What am I doing wrong? </p>