Drag to desktop

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
thehat
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 31
Joined: Mon Apr 16, 2007 5:32 am
Contact:

Drag to desktop

Post by thehat » Thu Sep 16, 2010 5:25 pm

I want to save an image that is on a card to either the desktop or a image folder as a jpeg file. Using drop and Drag would be cool.

I tried to drag the image to the desktop.
This doesn't work:
on dragStart
put ID of me into timage
set the dragData["image"] to image ID timage
end dragStart


Thanks for your help
Gregg

Klaus
Posts: 14208
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Drag to desktop

Post by Klaus » Thu Sep 16, 2010 6:30 pm

Hi Gregg,

unfortunately this does not work the way one would exspect and as you tried.
To get a copy of your image somewehre on the desktop or elsewhere, you need to manage "the dragdata["files"]!

Question:
Is this an internal (imported) or referenced image?

Anyway, here we go.
If it is referenced then you could do this:

Code: Select all

on dragStart
   set the dragData["files"] to the filename of me
end dragStart
If it is an internal (imported) image you will have to export it to a file first.
In my example I export it to the temp folder, so the user does not see it, which is preferrable :D

Code: Select all

on dragStart
   put specialfolderpath("temporary") & "/Name of your target image here.jpg" into tTargetfile
   export img "your image name here" to file tTargetfile as JPEG
   ## Rev is fast enough, the user will not see any delay!

   set the dragData["files"] to tTargetfile
end dragStart
Tested and works :D


Best from germany

Klaus

thehat
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 31
Joined: Mon Apr 16, 2007 5:32 am
Contact:

Re: Drag to desktop

Post by thehat » Thu Sep 16, 2010 10:24 pm

Thank so much. I did get that to work. I had to include .jpeg in the name of the image.
Then it worked like a charm!
Thanks again

Post Reply