diff --git a/Packages/vChewing_UpdateSputnik/Sources/UpdateSputnik/UpdateSputnik.swift b/Packages/vChewing_UpdateSputnik/Sources/UpdateSputnik/UpdateSputnik.swift index 5f8906d2..d3b2fd0b 100644 --- a/Packages/vChewing_UpdateSputnik/Sources/UpdateSputnik/UpdateSputnik.swift +++ b/Packages/vChewing_UpdateSputnik/Sources/UpdateSputnik/UpdateSputnik.swift @@ -112,7 +112,7 @@ public class UpdateSputnik { alert.informativeText = NSLocalizedString("You are already using the latest version.", comment: "") alert.addButton(withTitle: NSLocalizedString("OK", comment: "")) alert.runModal() - NSApp.setActivationPolicy(.accessory) + NSApp.activate(ignoringOtherApps: true) return } @@ -131,8 +131,8 @@ public class UpdateSputnik { alert.informativeText = content alert.addButton(withTitle: NSLocalizedString("Visit Website", comment: "")) alert.addButton(withTitle: NSLocalizedString("Not Now", comment: "")) - NSApp.setActivationPolicy(.accessory) let result = alert.runModal() + NSApp.activate(ignoringOtherApps: true) if result == NSApplication.ModalResponse.alertFirstButtonReturn { if let siteInfoURLString = plist[varkUpdateInfoPageURLKey] as? String, let siteURL = URL(string: siteInfoURLString) @@ -158,6 +158,6 @@ public class UpdateSputnik { alert.informativeText = content alert.addButton(withTitle: NSLocalizedString("OK", comment: "")) alert.runModal() - NSApp.setActivationPolicy(.accessory) + NSApp.activate(ignoringOtherApps: true) } } diff --git a/Source/Modules/AppDelegate.swift b/Source/Modules/AppDelegate.swift index a9550d84..a9a92a40 100644 --- a/Source/Modules/AppDelegate.swift +++ b/Source/Modules/AppDelegate.swift @@ -96,6 +96,7 @@ extension AppDelegate { alert.addButton(withTitle: NSLocalizedString("OK", comment: "")) alert.addButton(withTitle: NSLocalizedString("Not Now", comment: "")) let result = alert.runModal() + NSApp.activate(ignoringOtherApps: true) if result == NSApplication.ModalResponse.alertFirstButtonReturn { NSWorkspace.shared.openFile( LMMgr.dataFolderPath(isDefaultFolder: true), withApplication: "Finder" @@ -104,7 +105,6 @@ extension AppDelegate { isSudo: false, selfKill: true, defaultDataFolderPath: LMMgr.dataFolderPath(isDefaultFolder: true) ) } - NSApp.setActivationPolicy(.accessory) } /// 檢查該程式本身的記憶體佔用量。 diff --git a/Source/Modules/LMMgr.swift b/Source/Modules/LMMgr.swift index 5cbafb48..5bc36d97 100644 --- a/Source/Modules/LMMgr.swift +++ b/Source/Modules/LMMgr.swift @@ -611,7 +611,7 @@ public enum LMMgr { alert.informativeText = content alert.addButton(withTitle: NSLocalizedString("OK", comment: "")) alert.runModal() - NSApp.setActivationPolicy(.accessory) + NSApp.activate(ignoringOtherApps: true) } return false } diff --git a/Source/Modules/SessionCtl_Menu.swift b/Source/Modules/SessionCtl_Menu.swift index 8d161442..b154138c 100644 --- a/Source/Modules/SessionCtl_Menu.swift +++ b/Source/Modules/SessionCtl_Menu.swift @@ -204,11 +204,10 @@ extension SessionCtl { } else if NSEvent.modifierFlags.contains(.option) { CtlPrefWindow.show() } else { - NSApp.setActivationPolicy(.accessory) CtlPrefUI.shared.controller.show(preferencePane: SSPreferences.PaneIdentifier(rawValue: "General")) CtlPrefUI.shared.controller.window?.level = .statusBar - NSApp.activate(ignoringOtherApps: true) } + NSApp.activate(ignoringOtherApps: true) } @objc public func showCheatSheet(_: Any? = nil) { @@ -233,11 +232,11 @@ extension SessionCtl { "Please reconfigure the cassette path to a valid one before enabling this mode.", comment: "" ) let result = alert.runModal() + NSApp.activate(ignoringOtherApps: true) if result == NSApplication.ModalResponse.alertFirstButtonReturn { LMMgr.resetCassettePath() PrefMgr.shared.cassetteEnabled = false } - NSApp.setActivationPolicy(.accessory) } return } diff --git a/Source/Modules/WindowControllers/CtlAboutWindow.swift b/Source/Modules/WindowControllers/CtlAboutWindow.swift index 26af654d..4057b80d 100644 --- a/Source/Modules/WindowControllers/CtlAboutWindow.swift +++ b/Source/Modules/WindowControllers/CtlAboutWindow.swift @@ -22,7 +22,7 @@ class CtlAboutWindow: NSWindowController { sharedWindow.orderFrontRegardless() // 逼著視窗往最前方顯示 sharedWindow.level = .statusBar sharedWindow.titlebarAppearsTransparent = true - NSApp.setActivationPolicy(.accessory) + NSApp.activate(ignoringOtherApps: true) } override func windowDidLoad() { diff --git a/Source/Modules/WindowControllers/CtlClientListMgr.swift b/Source/Modules/WindowControllers/CtlClientListMgr.swift index 629cb889..653ab150 100644 --- a/Source/Modules/WindowControllers/CtlClientListMgr.swift +++ b/Source/Modules/WindowControllers/CtlClientListMgr.swift @@ -23,7 +23,7 @@ class CtlClientListMgr: NSWindowController, NSTableViewDelegate, NSTableViewData sharedWindow.orderFrontRegardless() // 逼著視窗往最前方顯示 sharedWindow.level = .statusBar sharedWindow.titlebarAppearsTransparent = true - NSApp.setActivationPolicy(.accessory) + NSApp.activate(ignoringOtherApps: true) } override func windowDidLoad() { diff --git a/Source/Modules/WindowControllers/CtlPrefWindow.swift b/Source/Modules/WindowControllers/CtlPrefWindow.swift index 743eaf43..b010aaad 100644 --- a/Source/Modules/WindowControllers/CtlPrefWindow.swift +++ b/Source/Modules/WindowControllers/CtlPrefWindow.swift @@ -54,7 +54,7 @@ class CtlPrefWindow: NSWindowController { sharedWindow.orderFrontRegardless() // 逼著視窗往最前方顯示 sharedWindow.level = .statusBar sharedWindow.titlebarAppearsTransparent = true - NSApp.setActivationPolicy(.accessory) + NSApp.activate(ignoringOtherApps: true) } private var currentLanguageSelectItem: NSMenuItem? diff --git a/UserPhraseEditor/CtlAboutWindow.swift b/UserPhraseEditor/CtlAboutWindow.swift index 73b29e2d..be993d80 100644 --- a/UserPhraseEditor/CtlAboutWindow.swift +++ b/UserPhraseEditor/CtlAboutWindow.swift @@ -22,7 +22,7 @@ import Cocoa sharedWindow.orderFrontRegardless() // 逼著視窗往最前方顯示 sharedWindow.level = .statusBar sharedWindow.titlebarAppearsTransparent = true - NSApp.setActivationPolicy(.accessory) + NSApp.activate(ignoringOtherApps: true) } override func windowDidLoad() {