When i minimize the application applicationDidEnterInBackground
not called for Mac Catalyst. After some search i found that Background delegate methods not called for Mac Catalyst but foreground method of Scene delegate called.
is there any way to track or handle minimize delegate methods like NSWindowDelegate
have?
Thanks
Well, if you check NSWindowDelegate.windowWillMiniaturize:
you'll notice that its parameter is just a notification (its name is NSWindowWillMiniaturizeNotification
).
So, you can simply observe that notification to get notified whenever a window in your app is about to be minimized:
NotificationCenter.default.addObserver(forName: NSWindow.willMiniaturizeNotification, object: nil, queue: nil) { notification in
print("This window is about to be minimized:", notification.object)
}
You can also do the same to get notified about other events like:
NSWindow.didMiniaturizeNotification
: After the window is minimized.NSWindow.didDeminiaturizeNotification
: After the window is restored/deminimized.NSWindow.willEnterFullScreenNotification
: Before entering full screen.NSWindow.didEnterFullScreenNotification
: After entering full screen.NSWindow.willExitFullScreenNotification
: Before exiting full screen.NSWindow.didExitFullScreenNotification
: After exiting full screen.Full list of notifications here.