The scene Commands are great way to create a main menu Like Project between the standard view || window menu on macOS,
Is there a way to construct submenus?
Currently the commands are listed in a main menu however is it possible to append a menu item that has its own submenu in SwiftUI?
Is there a way to construct submenus?
Currently the commands are listed in a main menu however is it possible to append a menu item that has its own submenu in SwiftUI?
You can create submenus using the Menu type (née MenuButton). This also works in other menu types, like context menus and pop-up buttons.
FYI, there are some known issues that prevent state changes from updating menu bar menus as expected, which more or less prevents sharing state between your main menu and your windows. This will be addressed in a future seed.
Code Block @main struct TestApp: App { var body: some Scene { WindowGroup { Text("Hello, SwiftUI!").padding() } .commands { CommandMenu("Example") { Button("Menu Item", action: ...) Divider() Menu("Submenu") { Button("Menu Item", action: ...) } } } } }
FYI, there are some known issues that prevent state changes from updating menu bar menus as expected, which more or less prevents sharing state between your main menu and your windows. This will be addressed in a future seed.