Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yanli0303/0c3585114ff51405775a9beb9891349b to your computer and use it in GitHub Desktop.
Save yanli0303/0c3585114ff51405775a9beb9891349b to your computer and use it in GitHub Desktop.
NSWindowController.close() does not stopModal or endSheet
import Cocoa
class FooWC: NSWindowController {
}
extension FooWC: NSWindowDelegate {
func windowWillClose(_ notification: Notification) {
guard let win = notification.object as? NSWindow else {
return
}
if win.isModalPanel {
NSApp.abortModal()
}
if let sheetParent = win.sheetParent {
sheetParent.endSheet(win)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment