UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Customize New command with Document based SwiftUI app

Forums > SwiftUI

I want to customize the New command in a SwiftUI app based on the document app template.

It would be "fine" to simply add a drop down menu in the file search dialog that is presented. I just need to let the user select between a few "custom" (run time) types of documents. The file types are all the same, but there is a string value that lets the .init function know how to setup the document.

So, anyone have an example of how to can add a drop down menu into the dialog that lets the user pick where to create the new file either on launch or via the New menu option?

1      

XCode itself might be a good template to follow?

When I tapped the New menu item in XCode, it presented 13 different options for me.

One of those (Group from selected) was enabled because I had one code file selected. If I deselected the code file, and tried New again, that option wasn't available. Sounds like what you want to achieve?

The point is, you might consider Apple's XCode as providing you a great example of how you might implement a similar feature in your cool app.

Apple's Keynote provides a different interface when you tap New. Keynote presents a dialog allowing you to select one of many themes and screen formats. If your applications is primarily document based, this might provide you an alternative design pattern.

Let us know what you decide!

1      

I am built on the XCode template. I will watch the presentation and see how that is different.

I am working on an editor for authors. I have templates of various vormats - novel, shortstory, anthology, etc. I want the user to be able to pick one of the templates (they can also create their own templates, so it has to be dynamic) to create a new project. Pretty much a dumbded down, simplified use of the same thing XCode does when you can pick various from templates (iOS, MacOS, etc) to create a new project.

I originally did this using Coredata and wrote my own open dialog. I don't see in the XCode Document Template how to hook into the New command. I do NOT want to give up all the file management the Document App does for me. I just want to add options to the New command.

1      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.