I'm trying to do a an status item with a single button that sounds a beep when pressed.
But nothing is playing when pressing. This is the code:
import SwiftUI
import AppKit
struct MenuView: View {
@State var currentTab = "Enabled"
var body: some View {
VStack{
HStack{
Button(action: {
NSSound.beep()
print("Beep")
}) {
Text("Hello wordl!")
} }
.padding(.horizontal)
.padding(.top)
Spacer(minLength: 0)
}.frame(width: 250, height: 300)
}
}
struct MenuView_Previews: PreviewProvider {
static var previews: some View {
MenuView()
}
}
Thanks in advance
Honestly, I can't see the issue with this, it looks fine, it's very simple code so its not like something under the hood could be breaking it and as @Sweeper said it works for him as it does for me.
I know this is gonna sound silly, but more often than I'd like to admit, its the silly things that stump me, are you sure you have you're sound on/turned up?