mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-09 17:19:59 +00:00
52 lines
1.5 KiB
Swift
52 lines
1.5 KiB
Swift
import Cocoa
|
|
|
|
|
|
class AppDelegate: NSObject {
|
|
var mainWindow: NSWindow?
|
|
var mainWindowController: NSWindowController?
|
|
var mainWindowViewController: ViewController?
|
|
}
|
|
|
|
extension AppDelegate: NSApplicationDelegate {
|
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
|
let window = NSPanel(
|
|
contentRect: NSZeroRect
|
|
, styleMask: [
|
|
.titled
|
|
, .closable
|
|
, .hudWindow
|
|
, .utilityWindow
|
|
, .nonactivatingPanel
|
|
]
|
|
, backing: .buffered
|
|
, defer: false)
|
|
|
|
window.title = "fx_cast"
|
|
window.orderFrontRegardless()
|
|
window.center()
|
|
|
|
let windowController = NSWindowController(window: window)
|
|
windowController.showWindow(window)
|
|
|
|
let viewController = ViewController()
|
|
window.contentViewController = viewController
|
|
window.makeKeyAndOrderFront(self)
|
|
|
|
self.mainWindow = window
|
|
self.mainWindowController = windowController
|
|
self.mainWindowViewController = viewController
|
|
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
}
|
|
|
|
func applicationDidResignActive(_ aNotification: Notification) {
|
|
self.mainWindow?.performClose(aNotification)
|
|
}
|
|
|
|
func applicationWillTerminate(_ aNotification: Notification) {}
|
|
|
|
func applicationShouldTerminateAfterLastWindowClosed(_ app: NSApplication) -> Bool {
|
|
return true
|
|
}
|
|
}
|