Re: Dropping files and folders on the application icon?
Re: Dropping files and folders on the application icon?
- Subject: Re: Dropping files and folders on the application icon?
- From: Nick Zitzmann <email@hidden>
- Date: Mon, 11 Aug 2003 20:30:16 -0700
On Monday, August 11, 2003, at 07:00 PM, R. Ecalcitrance wrote:
hi. I'm writing a little renaming program and I want to drop files and
folders on the application icon.
what is this called in cocoa?
I'm pretty sure this question has been asked and answered several times
before, so I'd suggest checking the archives...
<
http://cocoa.mamasam.com/>
in OS9 I would call 'AEInstallEventHandler' with 'kAEOpenDocuments'.
anyone know how to drop things on the application?
But since I'm so niiiiiiice and kiiiiiind <;*), I'll answer your
question... To do this in Cocoa, you must:
1. Write the following method in your NSApplication delegate object:
- (BOOL)application:(NSApplication *)app openFile:(NSString *)file;
(You can set the delegate by either calling [NSApp setDelegate:blah]
very early in your app's initialization, or using IB to hook it up. The
latter is probably a better idea.)
2. Set up the Info.plist file to accept the drop. You need to associate
the files you want your application to open by setting the Info.plist
entries inside the project's target in PB.
Then, when an icon is dragged onto the application,
-application:openFile: will be called, and the "file" NSString above
will contain the path to the file. You can also force the application
to open the file by holding down Command and Option while dragging to
the Dock icon, but I wouldn't recommend relying on that little
feature...
Nick Zitzmann
AIM/iChat: dragonsdontsleep
Check out my software page:
http://seiryu.home.comcast.net/
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my
telephone." - Bjarne Stroustrup
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.