mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-11 10:09:59 +00:00
Implement initial NativeMacReceiverSelector
This commit is contained in:
47
app/NativeMacReceiverSelector/AppDelegate.swift
Normal file
47
app/NativeMacReceiverSelector/AppDelegate.swift
Normal file
@@ -0,0 +1,47 @@
|
||||
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 applicationWillTerminate(_ aNotification: Notification) {}
|
||||
|
||||
func applicationShouldTerminateAfterLastWindowClosed(_ app: NSApplication) -> Bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user