Clean up shift-key checking and add it to more places

This commit is contained in:
Nate Weaver 2020-05-20 19:59:05 -05:00
parent 24338b135e
commit 1e1fc06e7b
4 changed files with 4 additions and 8 deletions

View File

@ -193,7 +193,7 @@ extension DetailWebViewController: WKNavigationDelegate {
public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
if navigationAction.navigationType == .linkActivated {
if let url = navigationAction.request.url {
Browser.open(url.absoluteString)
Browser.open(url.absoluteString, invertPreference: navigationAction.modifierFlags.contains(.shift))
}
decisionHandler(.cancel)
return

View File

@ -264,10 +264,8 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
}
@IBAction func openArticleInBrowser(_ sender: Any?) {
let invert = NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false
if let link = currentLink {
Browser.open(link, invertPreference: invert)
Browser.open(link, invertPreference: NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false)
}
}

View File

@ -237,7 +237,7 @@ protocol SidebarDelegate: class {
guard let feed = singleSelectedWebFeed, let homePageURL = feed.homePageURL else {
return
}
Browser.open(homePageURL)
Browser.open(homePageURL, invertPreference: NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false)
}
@IBAction func gotoToday(_ sender: Any?) {

View File

@ -296,10 +296,8 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
// MARK: - Actions
@objc func openArticleInBrowser(_ sender: Any?) {
let invert = NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false
if let link = oneSelectedArticle?.preferredLink {
Browser.open(link, invertPreference: invert)
Browser.open(link, invertPreference: NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false)
}
}