Hi,

I started playing with drag and drop, and I wrote the following:

When creating a new window controller, it runs:

$self->{Window}->registerForDraggedTypes (NSArray->arrayWithObjects ("NSFilenamesPboardType"));

I also define this method in the window controller:

sub performDragOperation {
my ($self, $sender) = @_;
my $pboard = $sender->draggingPasteboard;
if ($pboard->types->containsObject (NSFilenamesPboardType)) {
my $files = $pboard->propertyListForType (NSFilenamesPboardType);
for (0 .. $files->count - 1) {
my $file = $files->objectAtIndex ($_);
print "filename: $file\n";
}
}
return 1;
}

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. No errors get printed to the console at all, compilation or runtime. Inserting a 'print "wheee!\n";' reveals that the performDragOperation isn't being called. What am I doing wrong?

Also, on the topic of DND, how do I catch a file drag to the dock icon? I can't figure out how to get the dock icon as an object I can call registerForDraggedTypes on. All I can find are API calls to munge the dock icon's menu, or image.

Perhaps this could be your next example app, Sherm? :-)

-Dan

Reply via email to