On Friday, February 21, 2003, at 11:53 AM, Dan Mills wrote:
When creating a new window controller, it runs:
$self->{Window}->registerForDraggedTypes (NSArray->arrayWithObjects ("NSFilenamesPboardType"));
Good so far...
... which isn't where that method needs to be. The NSDraggingDestination protocol methods must be implemented by the object that's been registered - in this case, an NSWindow object.I also define this method in the window controller:
I was fully expecting it all to fail horribly, hopefully giving me some useful errors, but I was rather perplexed to find that nothing happens when I drag a file to the app window.As a convenience, NSWindow and NSView - and probably some other classes as well - provide default "do-nothing" implementations of the NSDraggingDestination methods. To do anything useful, these default methods need to be overridden in a subclass, and your drop target needs to be an instance of that subclass.
That's a problem, because CB doesn't yet support subclassing. So, D&D can be done if you're willing to write a custom subclass of your drop target in Objective-C, but it can't yet be done in pure Perl. :-(
That's an entirely different kettle of fish.Also, on the topic of DND, how do I catch a file drag to the dock icon?
The Finder handles the D&D aspect of that itself, and simply forwards a request to open the dropped documents to the application. Wil Sanchez' DropScript application is a good example of handling it in Objective-C - some time soon, I'd like to get around to a similar example in Perl.
I'll definitely be including a D&D example in the next CB version. Also, a document-based apps example, and custom GUI controls - both of which, like D&D, require custom subclasses of standard Cocoa classes.Perhaps this could be your next example app, Sherm? :-)
For now, though, I'm working on examples for user preferences and toolbars. As I said, I'd also like to release an example soon, of opening documents dropped on the dock icon.
sherm--
Heisenberg may have slept here.
