I have a script that copy files into another location, when they dropped onto an item in a drawer.
it works fine and does what it shall do, but there is dirty thing: When I drop down the files the App and the Finder hangs for 30 seconds with a spinning Beachball. After this time the App do the job and sthe state went to normal.
Can someone of you see an error or the section where this nasty delay will be produced? thx.
Michael
_start
property emptyBox : missing value
property fullBox : missing value
property fileList : {}
on loadBoxImages()
set emptyBox to load image “drag.tif”
set fullBox to load image “drop.tif”
end loadBoxImages
on setBoxImage(state)
if state is “full” then
set image of image view “dropzone” of drawer “drawer” of window “main” to fullBox
else if state is “empty” then
set image of image view “dropzone” of drawer “drawer” of window “main” to emptyBox
end if
end setBoxImage
on drag entered theObject drag info dragInfo
setBoxImage(“full”)
end drag entered
on conclude drop theObject drag info dragInfo
set image of image view “dropzone” of drawer “drawer” of window “main” to emptyBox
set preferred type of pasteboard of dragInfo to “file names”
set fileList to contents of pasteboard of dragInfo
set zielordner to “Kraftmobil_Platte:Users:mk:Desktop:mk”
repeat with currentItem in fileList
tell application “Finder”
duplicate (currentItem as POSIX file as alias) to zielordner with replace
end tell
end repeat
set preferred type of pasteboard of dragInfo to “”
end conclude drop
on drag exited theObject drag info dragInfo
setBoxImage(“empty”)
end drag exited
on drop theObject drag info dragInfo
if “file names” is in types of pasteboard of dragInfo then
return true
else
return false
end if
end drop
on awake from nib theObject
loadBoxImages()
end awake from nib
_stop