Open files on drag and drop (creating a droplet application)
Open files on drag and drop (creating a droplet application)
- Subject: Open files on drag and drop (creating a droplet application)
- From: Kevin Muldoon <email@hidden>
- Date: Fri, 1 Sep 2006 14:21:03 -0400
I am starting my journey into Objective-C/Cocoa development. I hope I
might find sympathetic ears in this forum.
One of my favorite ways of interacting with files is dragging &
dropping items onto the application icon, and since that is how I
write most of my applications (OOP AppleScript/ASS), I thought that
would be a great way to start developing ObjC-Cocoa.
By modifying the document types pList, I was able to make the Cocoa
Application highlight and launch when defined files are dragged over
it. Great start!
Then, using a class provided by Wilfredo Sánchez Vega's demo program
"DropScript", I was able to run the program successfully by using the
File --> Open command through a Cocoa connection. This is
encouraging. I can locate a file in the browser, select it and a
shell script will gzip the file! Neat!
(please see the code... http://www.wsanchez.net/papers/DropScript/)
The problem is that I cannot make the app function with the drag &
drop feature! My understanding is that the following line of code is
supposed to feed the array of paths into the class, but apparently
nothing seems to happen.
- (BOOL) application:(NSApplication *) anApplication openFiles:
(NSArray *) filenames {
[self runScriptWithFiles: [NSArray arrayWithObject: filenames]];
return YES;
}
I have also used this code with a single file drop as well, but with
no luck.
- (BOOL) application:(NSApplication *) anApplication openFile:
(NSString *) aFileName {
// [self runScriptWithFiles: [NSArray arrayWithObject: filenames]];
[self runScriptWithFiles: [NSArray arrayWithObject: aFileName]];
return YES;
}
Since drag & drop is such a basic feature of MacOS programs, I
thought you guys could steer me in the right direction. Seems I'm at
a stopping point far too early in the learning process!
Thanks for your help!
-- Kevin Muldoon
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden