Don't do shift-key detection in Browser

This commit is contained in:
Nate Weaver 2020-05-20 19:54:25 -05:00
parent e79cafc82e
commit 24338b135e
3 changed files with 10 additions and 8 deletions

View File

@ -6,16 +6,14 @@
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
//
import AppKit
import Foundation
import RSWeb
struct Browser {
static func open(_ urlString: String) {
let shouldInvertPreference = NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false
static func open(_ urlString: String, invertPreference invert: Bool = false) {
// Opens according to prefs.
open(urlString, inBackground: shouldInvertPreference ? !AppDefaults.openInBrowserInBackground : AppDefaults.openInBrowserInBackground)
open(urlString, inBackground: invert ? !AppDefaults.openInBrowserInBackground : AppDefaults.openInBrowserInBackground)
}
static func open(_ urlString: String, inBackground: Bool) {

View File

@ -182,7 +182,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
if let item = item as? NSMenuItem, item.keyEquivalentModifierMask.contains(.shift) {
item.title = Browser.titleForOpenInBrowserInverted
}
return currentLink != nil
}
@ -264,8 +264,10 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
}
@IBAction func openArticleInBrowser(_ sender: Any?) {
let invert = NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false
if let link = currentLink {
Browser.open(link)
Browser.open(link, invertPreference: invert)
}
}

View File

@ -296,8 +296,10 @@ 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)
Browser.open(link, invertPreference: invert)
}
}