I am currently porting an application (or rather, a VST plugin) from windows to OSX. I am new to OSX programming, but I am using Cocoa NSView added to the Carbon window (which I get from the host) using HICocoaCreateView.
Anywhoo ... Inside this view, I want to receive mouseMoved and mouseDragged events, but when dragging I also want to get these events even when the mouse leaves my NSView (as well as the parent window), but I just can't seem to do it.
In windows, I would do SetCapture on mouseDown to get all mouse events for a while. The closest thing I found in Cocoa is "addGlobalMonitorForEventsMatchingMask", but it is only 10.6+, and I hardly believe that it was impossible to do before. (After all, this is what is commonly used for draggable components such as scrollbars, etc.).
It drives me crazy!
UPDATE:
There's something called CGEventTapCreate, which, as far as I can tell from rare documents, looks like addGlobalMonitor ... but in Carbon. I did not understand how Carbon and Cocoa relate to each other and what works there. Is this possible, although my main material is Cocoa? (The window I get from the host can be either Cocoa or Carbon. It's really a mess.)
source