Drag & Drop an Image from a Webpage

Kay C Lan lan.kc.macmail at gmail.com
Thu Jun 14 12:01:45 EDT 2012


OK, have no more hair to pull out.

OS X 10.6.8, LC 5.5, FireFox, Safari

I can use Drag & Drop to drag an image.jpg file from the Finder onto my
stack and have it automatically imported, sized and moved as required. No
problem.

I can use Drag & Drop to drag text from a webpage onto my stack and insert
it into a field, no problem.

But for the life of me I can not Drag & Drop an image from a webpage onto
my stack and have it import.

Tried the following, pointed my browser to the webpage referred to below,
then dragged the image to my stack, the area on my stack is set up to
accept - set the dragAction to "copy", exactly the same as for Finder
files, the pointer changes to a + icon, and clearly the server sends data
to LC, just not as expected:

* put the dragData["image"] into tStore1*
 --produces empty, grrrrrr :-((((((

* put the dragData["files"] into tStore2*
 --produces empty
*
 put the dragData["text"] into tStore3*
 --I get the file name '
http://www.emma-maersk.com/gallery/photo/engine_2.jpg'

* put the dragData["htmlText"] into tStore4*
 --produces empty

* put the dragData["unicodeText"] into tStore5*
 --produces empty

* put URL "http://www.emma-maersk.com/gallery/photo/engine_2.jpg" into
tStore6*
 --puts a whole swag of what looks like it should be binary into tStore6,
it starts off: ˇÿˇ‡JFIFddˇÏDuckyKˇÓ&Adobed¿

* import paint from file URL tStore3*
 --causes an execution error:
 --image "nimage1": execution error at line 40 (import: can't open file,
mask file or display) near "ˇÿˇ‡", char 1
 --Note that the chars in quotes are the first four chars in tStore6 above.

* import paint from file URL "
http://www.emma-maersk.com/gallery/photo/engine_2.jpg"*
 --causes an execution error:
 --"nimage1": execution error at line 41 (import: can't open file, mask
file or display) near "ˇÿˇ‡", char 1
 --Note that the chars in quotes are the first four chars in tStore6 above.

 *import paint from file the dragData["image"]*
 --causes an execution error:
 --"nimage1": execution error at line 42 (import: can't open file, mask
file or display) char 1

* import paint from file the dragData["text"]*
 --causes an execution error:
 --"nimage1": execution error at line 43 (import: can't open file, mask
file or display) near "http://www.emma-maersk.com/gallery/photo/engine_2.jpg",
char 1

* set the imageData of image "nimage1" to tStore6*
 --looks like a TV image after a hurricane has blown your antenna away

 *set the content of image "nimage1" to tStore6*
 --looks like a TV image after a hurricane has blown your antenna away, and
a truck ran over it

Clearly, I could download the file, then import the file into my stack,
then delete the file, but I was hoping for a method to just pour it
straight into my stack without the extra steps.

I have a sneaking suspicion the answer is going to be one of those 'doh!'
moments, where I've been looking at it too long to see the blindingly
obvious.

I will add just one other caveat. Virtually 99% of the time when I go to
Drag and Drop to my stack the cursor will NOT change to a + icon the FIRST
time, only on second and subsequent Drags will the cursor change to a +
icon - it's as if LC misses the first dragEnter message where I set
dragAction to 'copy'. If I turn the Message Watcher on to see what happens,
then all Drag & Drop ceases to work, the cursor doesn't even change to a
'no entry' icon, it just remains as a pointer and no drag messages are
registered.

Any help very much appreciated. If I do not respond for a while it's
because I'm about to hit the road and will be webless for a day or so.



More information about the use-livecode mailing list