Hi,
How do you make an image in an image view draggable to another image view or the desktop?
Thanks,
Hi,
How do you make an image in an image view draggable to another image view or the desktop?
Thanks,
Hey, kel.
I apologize in advance for this post, which will be only half of an answer. It is possible to do this, but as far as I know, it’s not supported in applescript studio alone. You’ll need to subclass the image view, and add some code to it which will handle all of this for you in obj-c. How you configure this will depend on what exactly you’re trying to achieve, and what kind of support for dragging FROM the image view you are looking for. I’ll assume that you want to drag a file to an image view, and then have the ability to drag that image to another image view, other applications, the Finder, etc… and have it work as expected.
The key is finding a way to ‘remember’ what file (path) was dropped on the image view, so when you later go to drag it somewhere else you have a reference to the file’s path to give to whatever object receives the second drop. This is pretty easy, and should be able to be done with only a few methods in a custom image view subclass.
Unfortunately, I’m off to san fran early on wednesday for 4 days, and won’t be able to get any more done with this until I get back. I wish I had the code already figured out, but I’ll still have to mess with it to work the kinks out. Perhaps while i’m gone some of the more objc-savvy users, or image experts (maybe ktam), can chime in and help with the details. The code I’ve got going so far is a combination of methods from the following two apple pages…
http://developer.apple.com/documentation/Cocoa/Conceptual/DragandDrop/index.html
http://developer.apple.com/samplecode/CocoaDragAndDrop/listing2.html
The mouseDown: and performDragOperation: methods seem most important. If you’re still hung up on this when I get back on sunday I’ll contact you privately and we’ll find a solution.
Sorry I can’t provide instant gratification… 8)
j
Hi Jobu,
I was hoping that the way I was using the ‘drag’ handler was wrong, but I guess it isn’t implemented yet in ASS.
Dragging outside the application is not important. The AppleScript can handle that. I know that the drag and drop from outside the application is easy as shown in the example drag and drop.
The CocoaDragAndDrop looks like it should do it if I knew how to use it. Maybe I’ll come up with something else.
Thanks for the links and reply.
gl,
I believe jobu is half correct on this one. You can handle the drop to an image view using AppleScript alone (the Drag and Drop AS Studio example included with the Developers’ tools demonstrates this nicely) but dragging from an image view requires custom Cocoa code.
Jon