I'm building a macOS menu bar app with SwiftUI's new MenuBarExtra
API and running into a bit of an odd issue.
I've implemented a settings window that I can open with the following call:
if #available(macOS 13, *) {
NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil)
} else {
NSApp.sendAction(Selector(("showPreferencesWindow:")), to: nil, from: nil)
}
I've also set the Application is agent
flag to YES
in info my project's properties.
Unfortunately, whenever I open the settings window via the MenuBar, it opens in the background and isn't visible at all. I'm really not sure how to proceed from here. I've thought about the following:
- Programmatically change focus (Doesn't appear to exist)
- Open a separate window (This seems to not work due to the Agent setting)
Has anyone come across this issue and implemented a solution to it?