From 12b920b0afd887cf4fe9a37101eecd5f4af7a56e Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Sun, 15 Mar 2020 16:03:20 -0700 Subject: [PATCH] Fix window close behavior (fixes #48) --- Secretive/AppDelegate.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Secretive/AppDelegate.swift b/Secretive/AppDelegate.swift index 831c14d..7c6c07f 100644 --- a/Secretive/AppDelegate.swift +++ b/Secretive/AppDelegate.swift @@ -29,6 +29,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { window.makeKeyAndOrderFront(nil) window.titleVisibility = .hidden window.toolbar = toolbar + window.isReleasedWhenClosed = false if storeList.modifiableStore?.isAvailable ?? false { let plus = NSTitlebarAccessoryViewController() plus.view = NSButton(image: NSImage(named: NSImage.addTemplateName)!, target: self, action: #selector(add(sender:))) @@ -42,6 +43,12 @@ class AppDelegate: NSObject, NSApplicationDelegate { agentStatusChecker.check() } + func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool { + guard !flag else { return false } + window.makeKeyAndOrderFront(self) + return true + } + @IBAction func add(sender: AnyObject?) { var addWindow: NSWindow! let addView = CreateSecretView(store: storeList.modifiableStore!) {