隐藏 SwiftUI / MacOS 应用程序的编辑菜单

Tam*_*mas 4 macos swift swiftui

我的 MacOS 应用程序没有任何文本编辑功能。如何隐藏Edit自动添加到我的应用程序的菜单?我更喜欢在 SwiftUI 中执行此操作。

我希望下面的代码应该可以工作,但事实并非如此。

@main
struct MyApp: App {

var body: some Scene {
    WindowGroup {
        ContentView()
    }.commands {
        CommandGroup(replacing: .textEditing) {}
    }
}

}
Run Code Online (Sandbox Code Playgroud)

Chr*_*isR 6

据我所知,您无法隐藏整个菜单,您可以隐藏其中的元素组:

    .commands {
        CommandGroup(replacing: .pasteboard) { }
        CommandGroup(replacing: .undoRedo) { }
    }
Run Code Online (Sandbox Code Playgroud)