Catalyst/UIKitForMac: hide window instead of quitting

Hello,


does anyone know if there's a way to configure the app to hide its window when the user clicks on the red close button in the title bar, instead of quitting? If so, how?

Replies

As I know, you can copy "Application Scene Manifest" in the info.plist, then change its title to "UIApplicationSceneManifest-macos". Set it "SupportsMultipleScenes", then when you close the window, the app won't quit.


But when you reopen the window, its size will be the maximum size. not the same size as when you close it. And background audio will also stop. Although, NSTimer will continue to work.


In the app kit, you can do this to make the close button do the hide action, but you can't do this in Catalyst. I'm searching for a solution too.
Code Block Swift
import Cocoa
class VCWindowController : NSWindowController, NSWindowDelegate {
required init?(coder: NSCoder) {
super.init(coder: coder)
}
func windowShouldClose(sender: AnyObject) -> Bool {
NSApp.hide(nil)
return false
}
}



I am instead looking for a way to programatically close a window in Catalyst, but I can't seem to be able to find any resource about it...