Drag And Drop more than one file
The last page deals with dropping one file onto our field, but it is handy to be able to drop more than one file to add them to the list.
To do this we need to find out how many files are in the drop. We should be able to do this by finding out how many lines are in the dragFlavors:
put the number of lines in the dragFlavors into tMax
But there is a wee bug in SuperCard 4.1.2 which limits the dragflavors to 255 chars.
Luckily for us Chilton Webb supplies an Xcfn that does the job ListDragFlavors. This should be avalible sonn from
ChiltonWebb.com but at the moment (( Jan 2004) you can get it from
http://homepage.mac.com/chilton/.Public/ListDragFlavors.sc4.sit
For one file we used:
put dragData(1, "hfs " ) into tFilePath
That got the file path for the first file dragged on, we now need to loop through the list getting the file paths for all the files:
on mouseDrop
put the number of lines in listdragflavors() into tMax
put "" into tImageList
repeat with x = 1 to tMax
put dragData(x, "hfs " ) into tFilePath
put item 1 of dragData(x, "hfs ",type ) into tFileType
if AltIsGraphicFile( tFileType,tFilePath) then put CR& tFilePath after tImageList
end repeat
We end up with a list of paths in tImageList, so now we can run through them and add then to our field (and userProp of paths), after checking if thety are already there.
if tImageList is "" then return true
put the uImagePaths of me into tImagePaths
repeat with x = 1 to the number of lines in tImageList
if line x of tImageList is "" or line x of tImageList is in tImagePaths then next repeat
set the itemDel to colon
put last item of line x of tImageList into tFileName
if the number of lines in cd fld "imagelist" = 0
then
put tfileName into cd fld "imageList"
put line x of tImageList into tImagePaths
else
put CR&tfileName after cd fld "imageList"
put CR&line x of tImageList after tImagePaths
set the uImagePaths of cd fld "imageList" to the uImagePaths of cd fld "imageList"&CR&tFilePath
end if
set the uImagePaths of me to tImagePaths
end repeat
return true
end mouseDrop