openPanel in Cocoa-Applescript application


How do I get an open panel (for choosing a file or folder) in AppleScriptObjC (Cocoa-Applescript)??

In Applescript Studio I used to do like this:

	tell open panel
		set treat packages as directories to false
		set can choose directories to false
		set can choose files to true
		set allows multiple selection to false
		set prompt to "Select file"
	end tell
	set theNameTextField to theName
	set thePathTextField to thePath
	display open panel in directory theDesktopPathPOSIX for file types {theType} attached to window "main"

As far as I can figure out, I have to use NSOpenPanel, but how do I get this to work?

Please help, thanks

Do you want the panel to open as a sheet?

I would like the open panel to be attached to the main window, if that what you mean by “sheet”.

Shane has an example on sheets that you can download at Scripting Matters.