diff --git a/NetNewsWire/MainWindow/Detail/DetailViewController.swift b/NetNewsWire/MainWindow/Detail/DetailViewController.swift index 250e28de5..4d0e61b55 100644 --- a/NetNewsWire/MainWindow/Detail/DetailViewController.swift +++ b/NetNewsWire/MainWindow/Detail/DetailViewController.swift @@ -153,15 +153,20 @@ extension DetailViewController: WKScriptMessageHandler { mouseDidExit(link) } } +} - private func mouseDidEnter(_ link: String) { +// MARK: DetailWebViewControllerDelegate + +extension DetailViewController: DetailWebViewControllerDelegate { + + func mouseDidEnter(_ link: String) { guard !link.isEmpty else { return } statusBarView.mouseoverLink = link } - private func mouseDidExit(_ link: String) { + func mouseDidExit(_ link: String) { statusBarView.mouseoverLink = nil } } diff --git a/NetNewsWire/MainWindow/Detail/DetailWebViewController.swift b/NetNewsWire/MainWindow/Detail/DetailWebViewController.swift index f50fd8c5b..44579f34d 100644 --- a/NetNewsWire/MainWindow/Detail/DetailWebViewController.swift +++ b/NetNewsWire/MainWindow/Detail/DetailWebViewController.swift @@ -17,8 +17,14 @@ enum DetailWebViewState: Equatable { case article(Article) } +protocol DetailWebViewControllerDelegate: class { + func mouseDidEnter(_ link: String) + func mouseDidExit(_ link: String) +} + final class DetailWebViewController: NSViewController, WKUIDelegate { + weak var delegate: DetailWebViewControllerDelegate? var webview: DetailWebView! var state: DetailWebViewState = .noSelection { didSet { @@ -66,25 +72,13 @@ final class DetailWebViewController: NSViewController, WKUIDelegate { extension DetailWebViewController: WKScriptMessageHandler { func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { - if message.name == MessageName.mouseDidEnter, let link = message.body as? String { - mouseDidEnter(link) + delegate?.mouseDidEnter(link) } else if message.name == MessageName.mouseDidExit, let link = message.body as? String{ - mouseDidExit(link) + delegate?.mouseDidExit(link) } } - - private func mouseDidEnter(_ link: String) { - guard !link.isEmpty else { - return - } -// statusBarView.mouseoverLink = link - } - - private func mouseDidExit(_ link: String) { -// statusBarView.mouseoverLink = nil - } } // MARK: - WKNavigationDelegate