Hi All, this question has been asked before by others, without any success so far.
I'm using the following (standard) method to open the system provided settings screen for my macOS (only) app in SwiftUI.
var body: some Scene {
Settings {
PreferencesView()
}
if #available(macOS 13, *) {
// MenuBarExtra requires macOS 13, but SettingsLink used in here requires macOS 14
MenuBarExtra("...", image: "...") {
...
// this one requires macOS 14
if #available(macOS 14, *) {
SettingsLink() {
Text("Settings...")
}
} else {
Button {
NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil)
} label: {
Image(systemName: "gear")
}
}
}
}
}
I want to know when the settings window closes. onDisappear does not work as the settings window is not really closed, but hidden. So the view stays active. All other hacks I have found neither work.
Does anyone have any idea?