3

Apple's Clipboard Viewer app is tremendously helpful when implementing copy and paste. I'd like to have a similar thing for drag and drop, but I'm not sure how to start.

Normally the first step to implementing a drop target is to have your NSView call -registerForDraggedTypes. Is there any way to declare that you want to receive all possible types of drops? Or is there a lower-level API that one could use to get the pasteboard without needing to specifically register first?

1 Answer 1

2

I'm not 100% sure it works really in all cases but I have successfully be using something like:

[self registerForDraggedTypes: @[(NSString*)kUTTypeItem]];

Also look up th eother type items.

4
  • I think you're on the right track. This works for almost everything, and might be as good as we can do. Dragging a font from Font Book doesn't trigger it, for example, but I can't find any other app that accepts fonts, either, so I suspect that it's a "dyn." UTI that third-party apps wouldn't be able to depend on, either.
    – user241221
    Jan 2, 2014 at 1:11
  • For completeness, it might be a good idea to include all 8 "UTI Abstract Types" and 9 "UTI Concrete Types" ("that most other type identifiers are derived from" -- in fact only 7 of these 17 are root UTIs, and there doesn't seem to be any way to get "all root UTIs"), though in practice I haven't found anything yet (except things that are probably "dyn." types) that's not matched by kUTTypeItem.
    – user241221
    Jan 2, 2014 at 1:22
  • What do you mean by “pasteboard identifier”? Jan 2, 2014 at 3:57
  • Ah, sorry, ignore that pasteboard identifier rubbish. This has been copied code where I registered an own UTI in addition to kUTTypeItem and didn't care to think why it was there (just made it more generic for this answer). Jan 2, 2014 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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