I have a very specific question which I would really apprciate some help with. My question consists of two points:
1:
Let’s say I have two ongoing projects. These are called Hinduism and Judaism. The names are irrelevant, but they’re pictures. What I want, is for my app to display a little preview of these pictures inside a drop-panel. I whipped this up quickly in interface builder to illustrate what I’m thinking of:
So, what I’m really asking for I guess, is a way to display a preview of a set picture, at a set location, without it already being a resource in the project. That way, if it gets updated, my application will pick up the changes. I’ve thought about this and tried various things out, but I can’t think how it would be done. Any ideas?
2:
I want to be able to drag a replacement image onto the preview, and the image I drag on gets renamed to whatever the preview is of, and then movied to the preview’s location.
I can handle moving, renaming and whatnot, but haven’t used drop-panels (or that’s what I call them. you can see what I mean in my picture) before and don’t know how to handle things being dropped onto them.
I really, really hope that all made sense, and that somebody out there has any idea how to do even a small part of these things.
You should look at the AppleScript Studio example “Drag and Drop”. I think it covers all your questions like how to get the path to the dragged file. The thing it doesn’t mention is how to move the file. One way to move the file is with the Finder. Say I get back a path to a dropped file like:
“/Users/kel/Desktop/Picture 1.pdf”
To use the Finder to move it, you need to change to AppleScript type reference:
set u to “/Users/kel/Desktop/Picture 1.pdf”
set file_reference to (u as POSIX file) as alias
Say you wanted to move it to your home folder. Something like this:
set u to “/Users/kel/Desktop/Picture 1.pdf”
set h to “/Users/kel/”
set file_reference to (u as POSIX file) as alias
set home_reference to (h as POSIX file) as alias
tell application “Finder”
move file_reference to home_reference
end tell
You can also use a unix command to do this but I’m not too good at that.
Thank you for your help so far, I really appreciate it. I did a search on the site and on google and I can’t find out how to sho an image just by it’s location on the computer, without it being a reference in the application. Can I get the “preview” item from the info menu for it?
If an image is not part of your project, you can load it by specifying a POSIX path to
the image file. For example, if sunFlowers.png is stored on disk in /User/Me/Images,
you could load the image with the following statement:
set image of image view “artImages” of window “artWindow” to load image “/
User/Me/Images/sunFlowers.png”
That’s why I wrote how to change posix path to AppleScript path so you could move Finder items. Note that when moving with the Finder, you can replace a file with the same name using ‘with replacing’. I can’t remember how to do this with the unix ‘mv’ command.
on clicked theObject
if name of theObject = "loadimages" then
set image of image view "sculptor" of window "Window" to load image "/sculptor.jpg"
end if
end clicke