Support the Copy command in the timeline. Fix #114.

This commit is contained in:
Brent Simmons 2018-02-12 13:04:07 -08:00
parent 81e56ba84b
commit 09b8cd7811
2 changed files with 26 additions and 0 deletions

View File

@ -8,6 +8,14 @@
import AppKit
import Data
import RSCore
extension Article: PasteboardWriterOwner {
public var pasteboardWriter: NSPasteboardWriting {
return ArticlePasteboardWriter(article: self)
}
}
@objc final class ArticlePasteboardWriter: NSObject, NSPasteboardWriting {

View File

@ -214,6 +214,11 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
runCommand(markUnreadCommand)
}
@IBAction func copy(_ sender: Any?) {
NSPasteboard.general.copyObjects(selectedArticles)
}
func markOlderArticlesAsRead() {
// Mark articles the same age or older than the selected article(s) as read.
@ -422,6 +427,19 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
}
}
// MARK: NSUserInterfaceValidations
extension TimelineViewController: NSUserInterfaceValidations {
func validateUserInterfaceItem(_ item: NSValidatedUserInterfaceItem) -> Bool {
if item.action == #selector(copy(_:)) {
return NSPasteboard.general.canCopyAtLeastOneObject(selectedArticles)
}
return true
}
}
// MARK: - NSTableViewDataSource
extension TimelineViewController: NSTableViewDataSource {