2

Possible Duplicate:
How do I make an OS X application react when a file, picture, etc is dropped on its dock icon?

For some reason, if I drag and drop a file on my apps icon... it doesn't work unless the app is currently running.

Here is the current Info.plist entry for CFBundleDocumentTypes

        <array>
                <dict>
                        <key>CFBundleTypeExtensions</key>
                        <array>
                                <string>*</string>
                        </array>
                        <key>CFBundleTypeName</key>
                        <string>NSFilenamesPboardType</string>
                        <key>CFBundleTypeRole</key>
                        <string>None</string>
                </dict>
        </array>

Thoughts, opinions, tips, tricks?

Repo here: https://bitbucket.org/crewshin/maketx_dnd

Community
  • 1
  • 1
crewshin
  • 765
  • 9
  • 22
  • 2
    Hehe... yes of course other apps that allow drag and dropping seem to work just fine. I'm referring to an app that I'm creating... which doesn't work. :) – crewshin Jan 25 '13 at 17:30

1 Answers1

3

The launching behavior on drag/drop to icon comes from having the file types your application can handle defined in CFBundleDocumentTypes in your Info.plist file.

Your app is not launching because you declared that you do not understand any file type whatsoever.

<key>CFBundleTypeRole</key>
<string>None</string>

To declare your app can read a file type, you should use 'Viewer' or 'Editor' for the CFBundleTypeRole.

The documentation is somewhat unclear about using an * to specify CFBundleTypeExtensions. It used to be a valid way to specify your app can only all file types in 10.4 and earlier, but it may not work after OSX 10.6. Try setting it to an extension you can actually read.

Fruity Geek
  • 7,351
  • 1
  • 32
  • 41
  • Crap I should have made that aspect more clear. Sorry. The drag and drop functionality is there and it works perfectly... as long as my app is currently running. If it's not running before the drag and drop, it will open the app... but do nothing. I added a link to the repo in the original post if interested. – crewshin Jan 25 '13 at 17:53
  • I fully understood what you are saying. "Launching" implies starting your non-running application. – Fruity Geek Jan 25 '13 at 18:31
  • I've tried all three and none of them seem to make a difference. I've set it to Editor for now though. – crewshin Jan 25 '13 at 19:22
  • 1
    Added detail covering the possible issues with how you have used CFBundleTypeExtensions – Fruity Geek Jan 25 '13 at 19:44
  • Interesting. I tried setting that to jpg before but it didn't work. This time I added a few more entries to the array (jpg, tif, exr, tga, png) and now it seems to work. Thanks for the tips! – crewshin Jan 25 '13 at 20:30