Is there a way to determine what's being dragged during an onMouseDrag event? Specifically, I'd like to know if a window is being dragged.
I've tried the following: Accessibility API: Store the initial location of the active window, query window location again during drag and compare values. The problem with this method is that Accessibility API does not update the position of a window until mouse stopped moving (with primary mouse button still depressed). It gives updated position when mouse starts dragging again after a brief stop.
Attach an NSWindowDelegate to the active window: I'm fairly new to this so I'm unaware of a way to find the focused/active window's NSWindow.
Thanks in advance!
UPDATE: I used the Accessibility API to get the active window and attached an AXObserverRef to get a kAXMovedNotification. I added this observer to the run loop using CFRunLoopAddSource. The result is that the callback to the notification gets queued and fires multiple calls to it only when I stop dragging the window. Is there a way to get the callback to fire right away without being queued like this so that I get to run some code WHILE the window is being dragged and not when dragging stops?