Page 1 of 1

Drag & drop for copying standalone

Posted: Sun Apr 16, 2017 7:53 pm
by Peter@multidesk.se
I'm trying to build a function where I draw a standalone into a text field to copy it to a predetermined location on the hard drive.
Once there, I want to open it from the same application, but I can not make it work. What am I doing wrong?, is it not possible to handle standalones in this way?

Grateful for any help


on mouseDown
set the dragaction to copy
end mouseDown

on dragDrop
if "Pro-Cell" is in the dragdata
then
put the dragdata into thePath
if the platform is "MacOS"
then
set the itemdel to "/"
end if
if the platform is "Win32"
then
set the itemdel to "\"
end if
put item -1 of thePath into myFile
set the defaultFolder to specialFolderPath ("temporary")
put the defaultFolder into tempFolder
put "/" & "Pro-Cell" after tempFolder
if there is no folder tempFolder
then
create folder tempFolder
end if
load url thePath
replace ".app" with empty in myFile
put tempfolder & "/" & myFile into theNewPath
put url ("binfile:" & thePath) into url ("binfile:" & theNewPath)

launch theNewPath
else
beep
end if
end dragDrop



/// Peter

Re: Drag & drop for copying standalone

Posted: Sun Apr 16, 2017 8:39 pm
by Klaus
Hi Peter,

here a couple of hints:
1. No need to differ between Mac and Win here!
LC uses the Unix SLASH as path delimiter internally on ALL platforms!

2. "the dragdata" is an ARRAY!
Check -> the dragdata["files"]

3. "load url xyz" will only work with (from the dictionary) -> Any valid http or ftp URL.

4.

Code: Select all

on mouseDown
  set the dragaction to copy
end mouseDown
will not work, use:

Code: Select all

on dragenter
  set the dragaction to "copy"
end dragenter
5. and most important!
Mac apps are actually FOLDERS, so this will not work on a Mac at all!
Use SHELL with "ditto" on a Mac or "revCopyFolder".


Best

Klaus