There is a method that I didn't notice at first, NSSavePanel#setNameFieldStringValue, which sets the filename.
here is a complete example in macruby syntax:
def run_save_settings_dialog(sender)
dialog = NSSavePanel.savePanel
dialog.title = "Save Settings"
dialog.canCreateDirectories = true
dialog.showsHiddenFiles = true
dialog.nameFieldStringValue = "MyFile"
dialog.canChooseFiles = true
dialog.canChooseDirectories = false
dialog.allowsMultipleSelection = false
dialog.setDirectoryURL NSURL.fileURLWithPath("some/path")
if dialog.runModal == NSFileHandlingPanelOKButton
save_settings(dialog.URL)
end
end
def save_settings(file_url)
File.open(file_url.path, 'w') {|f| f.write "Stuff" }
end