mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-05-22 15:45:40 +00:00
Fixes #1052 This implements the about window as a custom window with a view controller. This lets us implement the proper responder chain so that our custom close window IBActions do the right thing. This has an additional benefit that we can easily customize this window going forward.
38 lines
914 B
Swift
38 lines
914 B
Swift
import Foundation
|
|
import Cocoa
|
|
import SwiftUI
|
|
|
|
class AboutController: NSWindowController, NSWindowDelegate {
|
|
static let shared: AboutController = AboutController()
|
|
|
|
override var windowNibName: NSNib.Name? { "About" }
|
|
|
|
override func windowDidLoad() {
|
|
guard let window = window else { return }
|
|
window.center()
|
|
window.contentView = NSHostingView(rootView: AboutView())
|
|
}
|
|
|
|
// MARK: - Functions
|
|
|
|
func show() {
|
|
guard let window = window else { return }
|
|
window.makeKeyAndOrderFront(nil)
|
|
}
|
|
|
|
//MARK: - First Responder
|
|
|
|
@IBAction func close(_ sender: Any) {
|
|
self.window?.performClose(sender)
|
|
}
|
|
|
|
@IBAction func closeWindow(_ sender: Any) {
|
|
self.window?.performClose(sender)
|
|
}
|
|
|
|
// This is called when "escape" is pressed.
|
|
@objc func cancel(_ sender: Any?) {
|
|
close()
|
|
}
|
|
}
|