Contents

commandsRemoved()

Removes all commands defined by the modified scene.

Declaration

nonisolated func commandsRemoved() -> some Scene

Return Value

A scene that excludes any commands defined by its children.

Discussion

WindowGroup, Window, and other scene types all have an associated set of commands that they include by default. Apply this modifier to a scene to exclude those commands.

For example, the following code adds a scene for presenting the details of an individual data model in a separate window. To ensure that the window can only appear programmatically, we remove the scene’s commands, including File > New Note Window.

@main
struct Example: App {
    var body: some Scene {
        ...

        WindowGroup("Note", id: "note", for: Note.ID.self) {
            NoteDetailView(id: $0)
        }
        .commandsRemoved()
    }
}

See Also

Defining commands