Displaying sheets

A couple of people have asked about displaying sheets. Unfortunately they can’t be handled fully in ASObjC as it stands – some Objective-C code is required.

I’ve written a step-by-step guide to what’s required, along with a sample project that includes code for showing all kinds of sheets: alerts, save panels, open panels, and custom sheets. You can download it from here:

http://www.scriptingmatters.com/ASObjC

Any feedback is welcome.

That’s Great Shane.
So far it works with Open Panel in my app. The Open Panel though isn’t working as expected:

on showOpenPanel_()
		set thePanel to current application's class "NSOpenPanel"'s openPanel()
		set my contextInfo to "Open"
		tell thePanel
			setMessage_("Choose file:")
			setExtensionHidden_(true)
			setShowsHiddenFiles_(true)
			setTreatsFilePackagesAsDirectories_(true)
			setCanChooseFiles_(true)
			setCanChooseDirectories_(true)
			setAllowsMultipleSelection_(true)
			setResolvesAliases_(true)
			-- The following method is deprecated in 10.6, but the alternative is inaccessible from ASObjC
		beginSheetForDirectory_file_types_modalForWindow_modalDelegate_didEndSelector_contextInfo_(missing value, missing value, {"txt"}, mainWindow, me, "sheetDidEnd:returnCode:contextInfo:", missing value)
		end tell
end showOpenPanel_

It won’t show files Just directories. I changed the options around several times but still no files showing in the panel. maybe I am missing something. Or is this what they mean by deprecated? And if there is no ASOC way with the deprecated method, can we run the new method from OBJ-C side?

I think we need this fixed by Chris Nebel and friends. In the end we really should be able to access these basic methods from the script if ASOC is to be a first class citizen, though I do enjoy your elegant workarounds. Without you and Craig we would be quite lost!

Thanks, Rob

Do you mean no files appear, or they just appear grayed out?

Try setting the show directories to false and then try multiple false and then both…

Are you sure there are .txt files in the directory?

Hi Shane,

Doh!

I just pasted your Open Panel handler in there and didn’t notice the “txt” so I set it to missing value (?) and it shows everything now.

Sorry- my mistake.

Rob

I should have explained that part, sorry.