1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-16 22:28:57 +00:00

Shows the auto-open dialogue only at most once.

This commit is contained in:
Thomas Harte 2019-09-21 18:01:16 -04:00
parent 61993f0687
commit 3e639e96e7

View File

@ -13,6 +13,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) { func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application. // Insert code here to initialize your application.
if NSDocumentController.shared.documents.count == 0 {
NSDocumentController.shared.openDocument(self)
}
} }
func applicationWillTerminate(_ aNotification: Notification) { func applicationWillTerminate(_ aNotification: Notification) {
@ -20,13 +24,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
} }
func applicationShouldOpenUntitledFile(_ sender: NSApplication) -> Bool { func applicationShouldOpenUntitledFile(_ sender: NSApplication) -> Bool {
// Decline to show the 'New...' selector by default, preferring to offer // Decline to show the 'New...' selector by default; the 'Open...'
// an 'Open...' dialogue. // dialogue has already been shown if this application was started
// without a file.
// //
// Obiter: I dislike it when other applications do this for me, but it // Obiter: I dislike it when other applications do this for me, but it
// seems to be the new norm, and I've had user feedback that showing // seems to be the new norm, and I've had user feedback that showing
// nothing is confusing. So here it is. // nothing is confusing. So here it is.
NSDocumentController.shared.openDocument(self)
return false return false
} }
} }