Can you drag an image form app to finder
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Can you drag an image form app to finder
Hi there,
Looking at the possibility of reversing the way i normally work with drag and drop.
Can i drag an image from the card and drop it into finder or any other application.
It would ideally behave as if i was dragging the image from the finder, in the way that that image is dropable most anywhere.
Looking at the possibility of reversing the way i normally work with drag and drop.
Can i drag an image from the card and drop it into finder or any other application.
It would ideally behave as if i was dragging the image from the finder, in the way that that image is dropable most anywhere.
Kind Regards
Gary
https://www.doobox.co.uk
Gary
https://www.doobox.co.uk
Re: Can you drag an image form app to finder
Hi Gary,
yep, this is possible somehow but a bit cumbersome, since you need to create a (temporary) file first
Do this "on dragstart":
Export a snapshot of the image or the image itslef to a file in the TEMP folder: specialfolderpath("temp")
and set the daragdata["files"] to that file (absolute pathname mandatory")
LiveCode is fast enough for this, please give it a try
Best
Klaus
yep, this is possible somehow but a bit cumbersome, since you need to create a (temporary) file first

Do this "on dragstart":
Export a snapshot of the image or the image itslef to a file in the TEMP folder: specialfolderpath("temp")
and set the daragdata["files"] to that file (absolute pathname mandatory")
Code: Select all
on dragstart
put specialfolderpath("temporary") & "/name for your image here.jpg" into tTempImage
export snapshot... to file tTempImage
## or maybe: put the text of img X into url("binfile:" & tTempImage)
## Need to check for errors of course ;-)
set the dragdata["files"] to TempImage
...
end dragstart

Best
Klaus
Re: Can you drag an image form app to finder
Yep, just tested with a little imported image and works!
I added this little script to my image:
Dragged onto my desktop and got a copy of that image named "name for your image here.jpg".
Coooool
I added this little script to my image:
Code: Select all
on dragstart
set the dragaction to "copy"
put specialfolderpath("temporary") & "/name for your image here.jpg" into tTempImage
put the text of img 1 into url("binfile:" & tTempImage)
set the dragdata["files"] to tTempImage
end dragstart
Coooool

Re: Can you drag an image form app to finder
Stuff like this, just makes me smile from ear to ear.
Thank's Klaus, that's going to work a treat
Thank's Klaus, that's going to work a treat

Kind Regards
Gary
https://www.doobox.co.uk
Gary
https://www.doobox.co.uk
Re: Can you drag an image form app to finder
!!! Klaus- That's *very* cool! 

Re: Can you drag an image form app to finder
Just not sure if i can write to "specialfolderpath("temporary")" in sandboxed environment.
So i will just write to my appsupport folder and then delete it after, to be on the safe side
So i will just write to my appsupport folder and then delete it after, to be on the safe side

Kind Regards
Gary
https://www.doobox.co.uk
Gary
https://www.doobox.co.uk
Re: Can you drag an image form app to finder
I also think you can use "tempname()" as a shorthand for the specialfolderpath stuff:
Code: Select all
put tempname() into tTempImage
put the text of img 1 into url("binfile:" & tTempImage)
Re: Can you drag an image form app to finder
Yep, but the filename is pre-defined with "tempname" and might not look so good in the finder or even scare the enduser:
tmp.470.bI32GXVY VS. nice pic.jpg
Saving in the documents folder an delete the file later is a good solution.
But you will need to SEND the delete command sometime in the future, since it is neccessary for the DRAG action
and we do not get notified when the user drops the image outside of the standalone/IDE!
Best
Klaus
tmp.470.bI32GXVY VS. nice pic.jpg

Saving in the documents folder an delete the file later is a good solution.
But you will need to SEND the delete command sometime in the future, since it is neccessary for the DRAG action
and we do not get notified when the user drops the image outside of the standalone/IDE!
Best
Klaus
Re: Can you drag an image form app to finder
??? Wha ??? I name all my files tmp.470.bI32GXVY... it's a perfectly lovely filename...
-
- VIP Livecode Opensource Backer
- Posts: 10051
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Can you drag an image form app to finder
I think I missed something: I see how to export the image to a known directory ("temp"), but how can we know the destination directory the user dragged to?
I submitted a request for that in the RQCC some time ago, but if there's a way to do it now I'd be very happy.
I submitted a request for that in the RQCC some time ago, but if there's a way to do it now I'd be very happy.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Can you drag an image form app to finder
Klaus can correct me if i'm wrong, but I suspect by setting the dragdata, its like setting the clipboard data. Its available to the system, so when you drop it on the desktop, the system takes over and (if the mode is set to copy) copies the file from where the dragdata says it was drug from, to wherever you drop it with LC never needing to know where in the system you dropped it.
Really great trick that.
Really great trick that.
FourthWorld wrote:I think I missed something: I see how to export the image to a known directory ("temp"), but how can we know the destination directory the user dragged to?
I submitted a request for that in the RQCC some time ago, but if there's a way to do it now I'd be very happy.
-
- VIP Livecode Opensource Backer
- Posts: 10051
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Can you drag an image form app to finder
Indeed it works well on both Mac and Win (though sadly not on Linux).
Interesting, since a bunch of us on the use-livecode list tried to sort out a method for determining the destination folder last year and we call came up empty. I guess it didn't occur to us to not bother, and simply let the OS figure that part out.
Interesting, since a bunch of us on the use-livecode list tried to sort out a method for determining the destination folder last year and we call came up empty. I guess it didn't occur to us to not bother, and simply let the OS figure that part out.

Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Can you drag an image form app to finder
Hi sturgis,
And that's the reason why I figured this out a couple of years ago!
I wanted to know WHERE the user drops something outside of LC but couldn't,
so I had to care take to let the OS take care of this
Best
Klaus
Exactly!sturgis wrote:Klaus can correct me if i'm wrong, but I suspect by setting the dragdata, its like setting the clipboard data. Its available to the system, so when you drop it on the desktop, the system takes over and (if the mode is set to copy) copies the file from where the dragdata says it was drug from, to wherever you drop it with LC never needing to know where in the system you dropped it.
And that's the reason why I figured this out a couple of years ago!
I wanted to know WHERE the user drops something outside of LC but couldn't,
so I had to care take to let the OS take care of this

Best
Klaus