Drag and drop onto application icon


I’m making a small application for semi-automatic e-mail creation with AppleScript Studio. Most of there e-mails will have a file attachment, and I’m currently working how to supply this information to the application:

I would like to be able to drag a file onto the application icon in the dock (while running), instead of the normal file picker. Is this possible? I’ve been able to add drag and drop support to button and text fields, but the dock icon would be a much better solution.

I’m grateful for any help!

Eivind Løland-Andersen, Norway

I made an application that accepted dropped files. Here’s how:

In IB connect the File’s Owner object from your nib file to the handler “open” under the application event handlers section. That’s it! It shows up in your applescript as ‘on open names’. The ‘names’ is a list of the dropped files, I think as posix paths.

Hi, and thank you for replying

I have tried that, but the dock icon still won’t accept drag and dropped files. (Even when forcing a file onto the icon with “alt + cmd”).

Is there are compile setting in Xcode i have to change, or something?

Btw. When adding open to files owner, Interface Builder adds the function “on open theObject the” to the script. The syntax is not correct and won’t compile until i remove “the”. I use Xcode 2.5 on Tiger.

I see the problem. I created a new project to test, the type was applescript application, and I got the result you mention. Then I created another new project, type applescript droplet, and got the result I mentioned. So you have to create an applescript droplet application from the new project menu if you want this capability.

Unfortunately I don’t know how to convert a regular application project to a droplet. You probably have to start with a new droplet application and work from that… copying your code and other stuff to the new project.

Thanks! I’ll give it a try. :slight_smile: