Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Files dragged on App Icon

Files dragged on App Icon
Thread Tools
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
Aug 1, 2001, 06:01 PM
 
How can I gain access from my program to files dragged on the application icon?
     
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Aug 2, 2001, 12:23 PM
 
Someone recently helped me out with this one so here is what I have learned from playing with this:

First you have to edit the active target of your program to allow it to read documents with the extensions you want ("*" for all, "fold" if you want folders, as well).

Then you have to implement the "openFile" method in your application's delegate:
"- (BOOL)application NSApplication *)theApplication openFile NSString *)filename"

This method will be called once for every file that is dropped on the icon. If you drop onto it while it is not open, this method will be called before the "applicationdidFinishLaunching" method (just a FYI).

Hope that helps,
Jeff.

Edited to remove smilies from code.

[ 08-02-2001: Message edited by: Apocalypse ]
Spectral Class
"Shedding Light on Innovation"
     
davecom  (op)
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
Aug 2, 2001, 11:53 PM
 
Thanks a bunch. You undoubtedly saved me a lot of time reading through horrible documentation.
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
Aug 3, 2001, 12:08 PM
 
If you're using an NSDocumentController, and the above method is *not* implemented in the app delegate, then -openDocumentWithContentsOfFile: will automatically be called on the NSDocumentController instance, which in turn will open up a document automatically if appropriate, etc.

But if you want to do something outside of opening up documents with files that are dropped on your app icon, then that app delegate method is the one to use.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:21 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2