Objective-c – mouse click events in an NSView subclass

cocoaeventsmousensviewobjective c

I have an NSView subclass that gets initialized with an OpenGL context and has a bunch of mouse event handling (onMouseDown, etc…). I have an app using it which has a main Cocoa window that contains the view and all the mouse events are working properly.

However, I'm trying to use it now in another app where i have a secondary window that pops open and gets initialized with the view and while i get mouse moved evets, I don't seem to get any mouse click (or keyboard for that matter) events whatsoever.

When I click and drag on the view, the entire window moves, which im guessing has to do why i dont get any mouse events. I have acceptsFirstResponder and acceptsFirstMouse returning YES and even have hitTest returning self for good measure.

Do you guys have any ideas what could be wrong?

Best Answer

You need to return NO from -mouseDownCanMoveWindow in your NSView subclass.

Related Topic