On Sunday, February 23, 2003, at 05:45 PM, Dan Mills wrote:

Would it be easy to subclass it in objc and just add a stub that calls a perl function? (or am I better off just waiting for the next CB? I'm not in a crazy hurry to get DND).

It depends on your requirements, and your willingness to delve into Objective-C.


If you know some Objective-C, it wouldn't be all that difficult to implement the NSDraggingDestination methods in such a way that they simply delegates the responsibilities. For example:

- (BOOL) prepareForDragOperation: (id <NSDraggingInfo>) sender {
if ([[self delegate] respondsToSelector: @selector(windowShouldPrepareForDragOperation:) ]) {
return [[self delegate] windowShouldPrepareForDragOperation: sender];
} else {
return NO;
}
}


On the other paw, if you don't know ObjC, and you're in no hurry to learn it, you may be better off waiting for CB 0.3 - it won't be very much longer.

Are you sure I don't need to subclass for that?

Yep - I just ran a test case to verify it.


I haven't read DropScript (I don't have an apple cvs login),

It's cool in the unique way it handles groups of dropped files - instead of opening them one at a time, it hands a list of filenames off as arguments passed to a command-line script. It's not absolutely essential to understanding how it's done, though - just a neat example.


but I looked around on google and found that I needed to add the accepted type(s) to the CFBundleDocumentTypes info.plist entry.

That's good advice, and accurate as far as it goes, but it's out of date. You no longer need to edit a .plist file by hand - just set up the relevant document type info in Project Builder's "Application Settings" pane. (It's safe to ignore the "Document Class" item for now; it's used by the NSDocumentManager class in document-based applications.)


I also read that the function called is application:openFile. I had openDocument () defined in MyApp.pm, which File->Open calls w/o problems. I added openFile () in MyApp.pm as well, but still nothing happens.

Nothing happens because - as you pointed out - the method you need to add to the application delegate (i.e. MyApp.pm) is "application:openFile", not just "openFile". The full Perl declaration for it would look something like this:


$OBJC_EXPORT{'application:openFile:'} = { 'args'=>'@@', 'return'=>'c' };
sub application_openFile {
        my ($self, $theApplication, $filename) = @_;
        if ( ... do something with $filename ... ) {
                return 1;
        } else {
                return 0;
        }
}

sherm--

Heisenberg may have slept here.



Reply via email to