File Screen

How do I get/activate the kind of file screen you get when you save as in TextEdit?

You can use choose file name as normal. If you want a save panel as a sheet, it gets more complicated.

Toddler tantrum I want my complicated save drop down!


Please :slight_smile:

Then you have a bit of work ahead of you. Start by looking at NSSavePanel in Xcode help. You’ll need to use savePanel() to get a reference to the panel, and then call the various methods to set it up how you want (allowed files, starting directory, etc). If you want to add an accessory view, you’re going to require a Custom View.

Unfortunately the API for showing the panel as a sheet has changed in 10.6. The deprecated version still works, and you can use that, but the new version uses blocks, something that I can’t see any way of supporting in ASObjC short of a custom Objective-C class.

The deprecated version will require a suitable savePanelDidEnd_… handler to retrieve the filename and directory.

Off you go…

Actually the deprecated method seems to generate an error when it hits savePanelDidEnd:…, so you’re out of luck until someone packages up a suitable Objective-C class you can add to your project. It’s fairly trivial to do, but tedious to type out in detail.

Thanks at least I know where I am now :)… New idea, new post!

Back to this I now understand how to open a kind of drop down panel.

script TestingAppDelegate
	property winmainWindow : missing value
	property winDropDown : missing value
	on subShowDropDown_(sender)
		tell class "NSApplication" of current application
			its sharedApplication's beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_(winDropDown, winmainWindow, me, "ednsheets", missing value)
		end tell
	end subShowDropDown_
	on subEndDropDown_(sender)
		winDropDown's orderOut_(me)
		tell class "NSApplication" of current application
			its sharedApplication's endSheet_(winDropDown)
		end tell
		--closing code can go here just like the old "on panel ended"!)
	end subEndDropDown_
	on applicationWillFinishLaunching_(aNotification)
		-- Insert code here to initialize your application before any files are opened 
	end applicationWillFinishLaunching_
	on applicationShouldTerminate_(sender)
		-- Insert code here to do any housekeeping before your application quits 
		return true
	end applicationShouldTerminate_
end script

But I don’t know how to put in a finder window type GUI like the save as in TextEdit.

I don’t have Snow Leopard so I have no idea about AppleScriptObjC syntax,
but there is a class NSSavePanel, which provides all functions.
A sample ObjC code is

NSSavePanel *panel = [NSSavePanel savePanel]; [panel setRequiredFileType:@"pdf"]; [panel beginSheetForDirectory:nil file:nil modalForWindow:[self window] modalDelegate:self didEndSelector:@selector(didEnd:returnCode:contextInfo:) contextInfo:NULL];

We needs us a craig :lol:

Unfortunately using the save and open panels as sheets raises the same problems as I posted elsewhere with alert sheets. There are workarounds, but they require delving into Objective-C.

If the save panels are preset type things, which is kind of what I’ve heard, then is there a way to add a file browser to the sheet as if we were adding it to a normal window?

Not really.

So absolutely nobody has got savepanel working?

If you mean as a sheet, yes, you can get it working – but it requires using an Objective-C class.

Oh I’m not bothered anymore it sounds too complicated but incase I want it in the future I’ll carry on the post (others of mine take priority like image wells).

So would I have to add on an objective-c script somehow?


Can I get a copy of this anywhere? (or if you know :wink: )

It’s just been discussed on Apple’s AppleScriptStudio mailing list.

Can you paste the URL for me please :slight_smile:

You can search the archives at