I have 3 NSButton’s setup in my nib with images on them, I am using them as drag areas(I tried using NSImageView as well with the same outcome). When I drag a file to the objects it just needs to get the file’s path, and do quite a bit with some application. When I drag a file to it, it starts running the script, then after about 5 seconds it stops for 5-10 seconds, then the icon of the file I dragged gets pulled back to the folder it was in( as if you had dragged a file to something that didn’t accept it), and then the script continues. Everything in the script works perfectly - it gets the file’s path and all, but it just has that strange pause and pull back of the file.
I have implemented on drop and on conclude drop, I have the same result when I do a quick simple task in the drop part and the remainder of the script in the on conclude part - as I do if I have everything in the on drop. Putting everything in the on conclude has the same effect.
The drag and drop pause is a common problem that often has no known cause, and sometimes no known cure. It seems most often linked to the use of image views, but has plagued people using other objects as drop zones, as well. I found that enclosing the code which evaluated my file in an “ignoring application responses/end ignoring” condition helped.
Without seeing some code, and perhaps the whole project there may be nothing we can do to help.
If you’re doing a drag and drop onto a Cocoa object in your interface you must avoid all use of the Finder in the ‘on drop the_object_ drag info drag_info_’ handler.
The reason for this is it seems the Finder can’t walk and chew gum at the same time. What I mean by this is the following. When you drag a file system object onto an interface object, the Finder has a role in handing those objects off to your application. If you then turn right around and hand the object back to the Finder, through your event handler, then the Finder will get caught up in this sort of temporary infinite loop for 20 seconds or so. After that, it will suddenly snap back to life and process the file like normal.
The key then is to avoid all use of the Finder if at all possible. If you only need information about a file, use the Standard Additions “info for” command. If you need to manipulate the file in some manner, such as moving it, you’ll probably have the best luck with a “do shell script” and using the ‘ditto --rsrc’ shell command to do your moving. You could also look into using the System Events application, but be warned, it’s Disk-Folder-File suite is rather buggy. The support is better in Panther, but in my experience, trying to set the file type and creator types of files with System Events in OS X 10.2.8 would fail without returning any error messages. I ended up having to delve into using some Objective-C code to correctly set that information in my dfontifier application.
Oh, also, be sure to connect a “on conclude drop” handler to the same object for which you connected the “on drop handler”. You don’t need to add any code for it, but you’ll need this blank handler to prevent the NSImageView or whatever object it is from doing its own built-in handling of the drag-and-drop.
For example, if you didn’t have that handler attached to an NSImageView, and a user were to drop a file onto it which happened to be an image, the NSImageView would be like “Oh cool! I like images!” and it’d replace the image you assigned to it with the one the user dropped onto it.