Hey everyone,
I just went to the Mavericks beta and now I am having issues with my open panel…
(old Code)
on showModalOpen_()
set myFile to {}
set thePanel to current application's NSOpenPanel's openPanel()
set myDirectoryPath to current application's |NSURL|'s fileURLWithPath_("/Volumes/images")
tell thePanel
setMessage_("Open File:")
-- setAllowedFileTypes_({"tif"})
setTitle_("My Open Panel")
setShowsHiddenFiles_(false)
setDirectoryURL_(myDirectoryPath)
setCanChooseFiles_(true)
setCanChooseDirectories_(true)
setAllowsMultipleSelection_(true)
set returnCode to runModal()
end tell
set returnCode to returnCode as integer
if returnCode = (current application's NSFileHandlingPanelOKButton) as integer then
set theURLs to thePanel's URLs() as list
set progressCount to count of theURLs
repeat with i from 1 to count of theURLs
tell item i of theURLs to set thePosixPath to |path|()
log thePosixPath
set hfsPath to (((thePosixPath as text) as POSIX file) as text)
log hfsPath
set end of myFile to hfsPath
log myFile
end repeat
else
log "Cancel pressed"
error -128
end if
end showModalOpen_
With this code I am now getting “Can’t get path of file “volume:2015_03 Fall:Documents:nameOfFile.xlsx”. (error -1728)”
I have looked on here and found the coding that Shane Stanley had put up in a post, but still have issues.
(new Code)
on showModalOpen_()
if not (current application's NSThread's isMainThread()) as boolean then
display alert "This script must be run from the main thread." buttons {"Cancel"} as critical
error number -128
end if
-- make panel
set openPanel to current application's NSOpenPanel's openPanel()
tell openPanel
-- set main values
its setMessage:"Your message here" -- AS's prompt
-- other values you *can* set
its setDirectoryURL:(current application's class "NSURL"'s fileURLWithPath:(POSIX path of (path to desktop))) -- AS's default directory
its setAllowsMultipleSelection:true -- AS's multiple selections allowed
its setAllowedFileTypes:missing value -- AS's of type. Provide missing value for all types
its setShowsHiddenFiles:false -- AS's invisibles; default is false
its setTreatsFilePackagesAsDirectories:false -- AS's showing package contents; default is false
its setTitle:"Choose a File" -- Panel's title; default is "Open"
its setPrompt:"Open" -- Override name on button; default is "Open"
its setCanChooseFiles:true -- whether it's like choose file; default is true
its setCanChooseDirectories:true -- whether it's like choose folder; default is false
its setResolvesAliases:true -- whether aliases are automatically resolved; default is true
end tell
-- show panel
set returnCode to openPanel's runModal()
if returnCode is (current application's NSFileHandlingPanelCancelButton) then
error number -128
end if
-- get chosen paths and tags
set thePosixPaths to (openPanel's |URL|()'s valueForKey:"path") as list
set theCount to (count thePosixPaths)
log theCount
end showModalOpen_
The problem I have here is that it only opens 1 file, even though I selected multiple files. I added “theCount” to see how many files it listed but there is only one. I also tried combining the two scripts, but failed at that.
I also have a feeling that my NSSave Panel is going to have issues also. I have found that it no longer likes the following code for my progress bar.
my performSelectorOnMainThread_withObject_waitUntilDone_("incrementMyProgress:", "Processing image " & theCounter & " of " & progressCount, true)
Can anyone help, Please…