Why won't a button using a Label
show in the keyboard shortcuts list (holding ⌘ key)?
struct ContentView: View {
var body: some View {
NavigationSplitView {
SidebarView()
} detail: {
Text("Hello, world")
}
}
}
struct SidebarView: View {
let items = [1, 2, 3, 4, 5, 6]
var body: some View {
List(items, id:\.self) { item in
Text("\(item)")
}
.toolbar {
Button {
// Do something
} label: {
Label("New", systemImage: "plus")
}
.keyboardShortcut("n") // Will NOT show in shortcuts list
Button("Play") {
// Do something
}
.keyboardShortcut("p") // Will show in shortcuts list
}
}
}
Am I doing something wrong or is this just yet another SwiftUI shortcoming?