-1

I'm working on a framework that's intended to be added to a native macOS application so that it can post events into the application's event queue in response to touch-screen events. In order to function properly, it needs to know when a drag-and-drop operation has started within the current application. (It doesn't need to know about drag-and-drop operations started anywhere else within the system.)

Is there any way to do that?

So far I've checked to see if any relevant notifications are posted to the application's shared notification center, but that didn't bear any fruit. I'm willing to use Objective-C method swizzling, but I'd prefer to avoid that if possible.

1 Answer 1

0

The method I've found so far is to use Objective-C method swizzling and replace these three methods with a function that calls my callback function and then calls the original method:

  • dragImage:at:offset:event:pasteboard:source:slideBack: on NSWindow
  • dragImage:at:offset:event:pasteboard:source:slideBack: on NSView
  • beginDraggingSessionWithItems:event:source: on NSView

I'm not 100% sure that will catch every drag-and-drop operation, but it's caught all the ones I've tested out so far.

Not the answer you're looking for? Browse other questions tagged or ask your own question.