views:

25

answers:

2

I think this should be a very easy one, but I cant find the answer on the docs.

I want to stop mouse dragging events which are in (or start in) my custom nsview subclass from causing the window to be dragged around the screen. How can I tell the window to stay still so i can interact with the view instead of dragging the whole window around? thanks.

+1  A: 

You need to implement mouseDragged: in your view. As documented, NSView's implementation simply passes the message to the next responder, which means that it will end up hitting the window. (Why? See “The Responder Chain” in the Cocoa Event-Handling Guide.) Responding to the message yourself prevents that, as long as you don't call up to the superclass implementation.

Peter Hosey
I do implement mouseDragged, JWWalkers answers was the trick. thank you
aks
+1  A: 

In addition to the matter of whether you handle mouseDragged, you may need to override mouseDownCanMoveWindow to return NO, or override isOpaque to return YES.

JWWalker
Thank you, mouseDownCanMoveWindow/isOpaque is exactly what I was looking for, not sure how i missed it in the docs
aks