Fix window close behavior (fixes #48)

This commit is contained in:
Max Goedjen 2020-03-15 16:03:20 -07:00
parent bfb4f80b8c
commit 12b920b0af
No known key found for this signature in database
GPG Key ID: E58C21DD77B9B8E8

View File

@ -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!) {