Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SwiftUI – Help Menu KeyboardShortcut Missing

All of my keyboard shortcuts show up in the menus as they should except for the help menu. The keyboard shortcut still works and does show in the menu once I’ve used the shortcut, but does not show by default as it should.

Xcode 14.3.1 building for 13.3.

Here’s the stripped down code just showing the help menu.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

@main
struct MyApp: App {

    init() {
        NSWindow.allowsAutomaticWindowTabbing = false
    }

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

                Button {
                    NSWorkspace.shared.open(URL(string: "https://www.example.com")!)
                } label: {
                    Text("MyApp Help")
                }
                .keyboardShortcut("H")
            }
        }
    }
}

>Solution :

⌘H is already used by the system in a previous menu ("Hide ____"), so it’s likely not showing up because of the collision.

enter image description here

If you switch it to something that isn’t taken yet, it shows up fine.

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading