Post

Replies

Boosts

Views

Activity

How can an app be deminimized when clicking on its app icon in a full SwiftUI app?
When a macOS SwiftUI app is minimized and the dock icon is clicked. The app won't be deminimized and put to the front just like other native apps do. /* macOS Monterey: 12.3.1 (21E258) Xcode: 13.3.1 (13E500a) Swift: 5 */ import SwiftUI @main struct MyApp: App { @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate var body: some Scene { WindowGroup { MainView() } } } class AppDelegate: NSObject, NSApplicationDelegate { func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool { // THIS IS NEVER CALLED!!! if !flag { for window: AnyObject in sender.windows { window.makeKeyAndOrderFront(self) } } return true } }
1
0
784
Apr ’22