From ef0cc56252df2b8b475074424d867bc384dc8eb5 Mon Sep 17 00:00:00 2001 From: Isaac <105081832+rosedalerk@users.noreply.github.com> Date: Thu, 27 Apr 2023 00:15:43 -0700 Subject: [PATCH] make it so if click the app icon in the dock, open a window --- Mathboard/AppDelegate.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Mathboard/AppDelegate.swift b/Mathboard/AppDelegate.swift index e7aaa43..0a2aea9 100644 --- a/Mathboard/AppDelegate.swift +++ b/Mathboard/AppDelegate.swift @@ -32,5 +32,21 @@ class AppDelegate: NSObject, NSApplicationDelegate { func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { return true } + + func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool { + if !flag { + for window: NSWindow in sender.windows { + if let windowController = window.windowController { + // Check if the window is an instance of your main window controller + if windowController is HelloWindowController { + window.makeKeyAndOrderFront(self) + break + } + } + } + } + return true + } + }