LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
on dragEnter
set the dragaction to "copy"
end dragEnter
on dragDrop
put the dragdata["files"]
end dragDrop
And ended with this in the msg: /Users/klaus2/Desktop/Linie 5x ab Hasetor.pdf
/Users/klaus2/Desktop/M1 Vitihof -> City.pdf
/Users/klaus2/Desktop/Neue Filme November 2021.rtf
/Users/klaus2/Desktop/monty.jpg
I think this speaks for itself!
We all know how users are, so this is neccessary in my opinion.
So am I right that you want to ensure only 1 file is acted on, in case user drops more than one file? In that case would it not be better to warn the user rather than take one of the files, namely the first one in the list?
kaveh1000 wrote: Fri Nov 26, 2021 9:59 pm
So am I right that you want to ensure only 1 file is acted on, in case user drops more than one file?
Exactly!
kaveh1000 wrote: Fri Nov 26, 2021 9:59 pmIn that case would it not be better to warn the user rather than take one of the files, namely the first one in the list?
The problem here is that I am dragging a file into a field. Allowing multiple files would be confusing. So it is quite logical to say you cannot drag multiple files. I am now using:
on dragdrop
get dragData["files"]
if the number of lines of it > 1 then
answer "Please drag in only one file"
exit dragdrop
end if
get URL ("file:" & the dragData["files"])
put textdecode(it,"UTF8") into fld "original"
end dragdrop
hint:
Do not use IT more than neccessary, since IT may change when you least exspect IT!
Use an extra variable, which fortunately does not cost extra money:
on dragdrop
put the dragData["files"] into tFile
if the number of lines of tFile > 1 then
answer "Please drag in only one file"
exit dragdrop
end if
put URL ("file:" & tFile) into tFileContent
put textdecode(tFileContent,"UTF8") into fld "original"
end dragdrop