Drag & Drop

Klaus Major k_major at os.surf2000.de
Mon Mar 17 07:42:01 EST 2003


Hi Rolf,

> Can anyone explain what has to be scripted to have a Stack, where
> one can drop a File from the Finder into an img grc and then,
>  the Stack would put the path of the droped file into the message box.

here is a simple handler that i put into the card-script of my
drag'n'drop test stack (only one card ;-)...

It requires an image, a field and a player:
Very basic, but should gt you started :-)


on dragenter
   set the acceptdrop to true
end dragenter

on dragdrop
   put the dragdata
## That's it... This line will put the path = dragdata into the msg.
## Then after i check where to put the files, if at all...

   switch char -4 to -1 of the dragdata   ## the suffix!
   case ".gif"
   case ".jpg"
   case ".png"
      set the fileame of img 1 to the dragdata
     break
   case ".txt"
     put url("file:" & the dragdata) into fld 1
     break
   case ".rtf"
     set the rtftext of fld 1 to url("file:" & the dragdata)
     break
   case ".mov"
   case ".swf"
   case ".avi"
   case ".mpg"
     set the filename of player 1 to the dragdata
     break
   end switch
end dragdrop

Hope that helps...


Regards

Klaus Major
k_major at os.surf2000.de




More information about the use-livecode mailing list