AboutWindow adjustments

Allow opening links in default browser
Close window on Esc
Add rounded corners
lastfm
Dzmitry Neviadomski 2022-06-22 19:01:42 +03:00
parent 05eb1c38a0
commit 43467b6978
1 changed files with 19 additions and 2 deletions

View File

@ -8,7 +8,7 @@
import Cocoa
import WebKit
class AboutWindowController: NSWindowController {
class AboutWindowController: NSWindowController, WKNavigationDelegate {
@IBOutlet weak var appName: NSTextField!
@IBOutlet weak var appVersion: NSTextField!
@ -30,6 +30,8 @@ class AboutWindowController: NSWindowController {
creditsView.setValue(false, forKey: "drawsBackground")
vfxView.wantsLayer = true
vfxView.layer?.cornerRadius = 4
// fill up labels
@ -49,6 +51,21 @@ class AboutWindowController: NSWindowController {
}
}
creditsView.navigationDelegate = self
}
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
if navigationAction.navigationType == .linkActivated,
let url = navigationAction.request.url {
NSWorkspace.shared.open(url)
decisionHandler(.cancel)
return
}
decisionHandler(.allow)
}
@objc func cancel(_ sender: Any?) {
close()
}
}