I'm trying to programmatically open MenuBarExtra in Swift on macOS using a global keyboard shortcut. I've already setup all the code for the keyboard shortcut but I can't figure out how to show/hide the MenuBarExtra using SwiftUI. Is there a way of doing so in native SwiftUI which I can't seem to find? Otherwise, is there a way of doing so via AppKit?
I've defined my menubar app the in the following way:
MenuBarExtra("Title", image: "sample_icon", content: {
ContentView()
.preferredColorScheme(.dark)
})