Merge pull request #571 from vincode-io/Issue-517

Added ability to move between timeline and detail using arrows.  Issue #267
This commit is contained in:
Brent Simmons 2019-03-04 11:33:09 -08:00 committed by GitHub
commit 68cabaab51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 108 additions and 1 deletions

View File

@ -7,6 +7,10 @@
objects = {
/* Begin PBXBuildFile section */
5127B238222B4849006D641D /* DetailKeyboardDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5127B236222B4849006D641D /* DetailKeyboardDelegate.swift */; };
5127B239222B4849006D641D /* DetailKeyboardDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5127B236222B4849006D641D /* DetailKeyboardDelegate.swift */; };
5127B23A222B4849006D641D /* DetailKeyboardShortcuts.plist in Resources */ = {isa = PBXBuildFile; fileRef = 5127B237222B4849006D641D /* DetailKeyboardShortcuts.plist */; };
5127B23B222B4849006D641D /* DetailKeyboardShortcuts.plist in Resources */ = {isa = PBXBuildFile; fileRef = 5127B237222B4849006D641D /* DetailKeyboardShortcuts.plist */; };
519B8D332143397200FA689C /* SharingServiceDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519B8D322143397200FA689C /* SharingServiceDelegate.swift */; };
51EC114C2149FE3300B296E3 /* FolderTreeMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EC114B2149FE3300B296E3 /* FolderTreeMenu.swift */; };
6581C73820CED60100F4AD34 /* SafariExtensionHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6581C73720CED60100F4AD34 /* SafariExtensionHandler.swift */; };
@ -729,6 +733,8 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
5127B236222B4849006D641D /* DetailKeyboardDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailKeyboardDelegate.swift; sourceTree = "<group>"; };
5127B237222B4849006D641D /* DetailKeyboardShortcuts.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = DetailKeyboardShortcuts.plist; sourceTree = "<group>"; };
519B8D322143397200FA689C /* SharingServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingServiceDelegate.swift; sourceTree = "<group>"; };
51EC114B2149FE3300B296E3 /* FolderTreeMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = FolderTreeMenu.swift; path = AddFeed/FolderTreeMenu.swift; sourceTree = "<group>"; };
51EC1194214A94AC00B296E3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = NetNewsWire/Base.lproj/AddFeedFromListSheet.xib; sourceTree = SOURCE_ROOT; };
@ -1029,6 +1035,15 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
5127B235222B4849006D641D /* Keyboard */ = {
isa = PBXGroup;
children = (
5127B236222B4849006D641D /* DetailKeyboardDelegate.swift */,
5127B237222B4849006D641D /* DetailKeyboardShortcuts.plist */,
);
path = Keyboard;
sourceTree = "<group>";
};
6581C73620CED60100F4AD34 /* Safari Extension */ = {
isa = PBXGroup;
children = (
@ -1343,6 +1358,7 @@
84D52E941FE588BB00D14F5B /* DetailStatusBarView.swift */,
849A979A1ED9EFEB007D329B /* styleSheet.css */,
849A979B1ED9EFEB007D329B /* template.html */,
5127B235222B4849006D641D /* Keyboard */,
);
path = Detail;
sourceTree = "<group>";
@ -2218,6 +2234,7 @@
840F7CA321BDA4B40057E851 /* MainWindow.storyboard in Resources */,
840F7CA521BDA4B40057E851 /* styleSheet.css in Resources */,
840F7CA621BDA4B40057E851 /* Preferences.storyboard in Resources */,
5127B23B222B4849006D641D /* DetailKeyboardShortcuts.plist in Resources */,
840F7CC121BDAD2C0057E851 /* Credits.rtf in Resources */,
840F7CA721BDA4B40057E851 /* RenameSheet.xib in Resources */,
840F7CA821BDA4B40057E851 /* Inspector.storyboard in Resources */,
@ -2243,6 +2260,7 @@
849A97951ED9EF7A007D329B /* IndeterminateProgressWindow.xib in Resources */,
844B5B651FEA11F200C7C76A /* GlobalKeyboardShortcuts.plist in Resources */,
849A978F1ED9EE72007D329B /* DefaultFeeds.plist in Resources */,
5127B23A222B4849006D641D /* DetailKeyboardShortcuts.plist in Resources */,
845479881FEB77C000AD8B59 /* TimelineKeyboardShortcuts.plist in Resources */,
849A979D1ED9EFEB007D329B /* template.html in Resources */,
849A97A91ED9F9AA007D329B /* AddFeedSheet.xib in Resources */,
@ -2382,6 +2400,7 @@
840F7C2F21BDA4B40057E851 /* SidebarCellLayout.swift in Sources */,
840F7C3021BDA4B40057E851 /* SmartFeedPasteboardWriter.swift in Sources */,
840F7C3121BDA4B40057E851 /* SmartFeedsController.swift in Sources */,
5127B239222B4849006D641D /* DetailKeyboardDelegate.swift in Sources */,
840F7C3221BDA4B40057E851 /* SidebarViewController.swift in Sources */,
840F7C3321BDA4B40057E851 /* SidebarOutlineView.swift in Sources */,
840F7C3421BDA4B40057E851 /* Author+Scriptability.swift in Sources */,
@ -2508,6 +2527,7 @@
84CC88181FE59CBF00644329 /* SmartFeedsController.swift in Sources */,
849A97661ED9EB96007D329B /* SidebarViewController.swift in Sources */,
849A97641ED9EB96007D329B /* SidebarOutlineView.swift in Sources */,
5127B238222B4849006D641D /* DetailKeyboardDelegate.swift in Sources */,
8405DD9922153B6B008CE1BF /* TimelineContainerView.swift in Sources */,
D5A2678C20130ECF00A8D3C0 /* Author+Scriptability.swift in Sources */,
84F2D5371FC22FCC00998D64 /* PseudoFeed.swift in Sources */,

View File

@ -63,6 +63,17 @@ final class DetailViewController: NSViewController, WKUIDelegate {
override func scrollPageDown(_ sender: Any?) {
currentWebViewController.scrollPageDown(sender)
}
// MARK: - Navigation
func focus() {
guard let window = currentWebViewController.view.window else {
return
}
window.makeFirstResponderUnlessDescendantIsFirstResponder(currentWebViewController.view)
}
}
// MARK: - DetailWebViewControllerDelegate

View File

@ -11,6 +11,17 @@ import WebKit
final class DetailWebView: WKWebView {
weak var keyboardDelegate: KeyboardDelegate?
// MARK: - NSResponder
override func keyDown(with event: NSEvent) {
if keyboardDelegate?.keydown(event, in: self) ?? false {
return
}
super.keyDown(with: event)
}
// MARK: NSView
override func willOpenMenu(_ menu: NSMenu, with event: NSEvent) {

View File

@ -27,7 +27,9 @@ final class DetailWebViewController: NSViewController, WKUIDelegate {
}
}
}
private let keyboardDelegate = DetailKeyboardDelegate()
private struct MessageName {
static let mouseDidEnter = "mouseDidEnter"
static let mouseDidExit = "mouseDidExit"
@ -52,6 +54,7 @@ final class DetailWebViewController: NSViewController, WKUIDelegate {
webview = DetailWebView(frame: NSRect.zero, configuration: configuration)
webview.uiDelegate = self
webview.navigationDelegate = self
webview.keyboardDelegate = keyboardDelegate
webview.translatesAutoresizingMaskIntoConstraints = false
if let userAgent = UserAgent.fromInfoPlist() {
webview.customUserAgent = userAgent

View File

@ -0,0 +1,40 @@
//
// DetailKeyboardDelegate.swift
// NetNewsWire
//
// Created by Maurice Parker on 3/1/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import AppKit
import RSCore
@objc final class DetailKeyboardDelegate: NSObject, KeyboardDelegate {
let shortcuts: Set<KeyboardShortcut>
override init() {
let f = Bundle.main.path(forResource: "DetailKeyboardShortcuts", ofType: "plist")!
let rawShortcuts = NSArray(contentsOfFile: f)! as! [[String: Any]]
self.shortcuts = Set(rawShortcuts.compactMap { KeyboardShortcut(dictionary: $0) })
super.init()
}
func keydown(_ event: NSEvent, in view: NSView) -> Bool {
if MainWindowKeyboardHandler.shared.keydown(event, in: view) {
return true
}
let key = KeyboardKey(with: event)
guard let matchingShortcut = KeyboardShortcut.findMatchingShortcut(in: shortcuts, key: key) else {
return false
}
matchingShortcut.perform(with: view)
return true
}
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>key</key>
<string>[leftarrow]</string>
<key>action</key>
<string>navigateToTimeline:</string>
</dict>
</array>
</plist>

View File

@ -331,6 +331,10 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
sidebarViewController?.focus()
}
@IBAction func navigateToDetail(_ sender: Any?) {
detailViewController?.focus()
}
@IBAction func goToPreviousSubscription(_ sender: Any?) {
sidebarViewController?.outlineView.selectPreviousRow(sender)
}

View File

@ -8,5 +8,11 @@
<key>action</key>
<string>navigateToSidebar:</string>
</dict>
<dict>
<key>key</key>
<string>[rightarrow]</string>
<key>action</key>
<string>navigateToDetail:</string>
</dict>
</array>
</plist>