My code:
Button(action: {
AudioServicesPlaySystemSound(1026)
isActive.toggle()
}){
HStack{
Image(systemName: "trash")
Text("delete")
}
}
.foregroundColor(.red)
.font(.body)
.keyboardShortcut("b",modifiers: [])
in this stage keyboardShortcut is working but when I add buttonStyle keyboardShortcut is not working
code with buttonStyle:
Button(action: {
AudioServicesPlaySystemSound(1026)
isActive.toggle()
}){
HStack{
Image(systemName: "trash")
Text("delete")
}
}
.buttonStyle(PlainButtonStyle())
.foregroundColor(.red)
.font(.body)
.keyboardShortcut("b",modifiers: [])
2
Answers
works well for me on macos 12.beta, xcode 13.beta, target ios 14.7 and MacCatalyst 12. Tested on macOS 12 MacCatalyst app. What system are you using?
I had the same Issue, but If I use
BorderlessButtonStyle()
instead ofPlainButtonStyle
, works for me.