Reputation: 123
I would like to know if there is a possibility to use choose file like "Choose file sheet" if the answer is yes could you give me an example?
Upvotes: 0
Views: 178
Reputation: 3412
Sheets are a bit of a pain with AppleScriptObjC, but Myriad Helpers helps a lot. To use the NSOpenSave+MyriadHelpers category, add their .h and .m files to your Xcode project using the File > Add Files to … menu item. From a new (default) AppleScript App project, for example, you could do something like:
on applicationDidFinishLaunching_(aNotification)
tell current application's NSOpenPanel's openPanel()
its setMessage:"Please select a file:"
its setPrompt:"Choose"
its setDirectoryURL:(current application's NSURL's fileURLWithPath:(POSIX path of (path to desktop)))
its setCanChooseFiles:true
its setCanChooseDirectories:false
its setAllowsMultipleSelection:true
its setAllowedFileTypes:{"png"} -- list of extensions or UTIs
its showOver:theWindow calling:{"panelCompletion:", me}
end tell
end
on panelCompletion:openItems
if openItems is missing value then -- "Cancel" button
log "Cancel"
return -- or whatever
end if
repeat with anItem in openItems as list
log anItem -- do your thing with the individual file paths
end repeat
end panelCompletion:
Upvotes: 1