Changed timeline behavior to scroll selected entry to middle when next selected entry isn't visible. Issue #604

This commit is contained in:
Maurice Parker 2019-04-12 11:13:19 -05:00
parent 9d4f00f3d7
commit d2fe0bd4d4
2 changed files with 57 additions and 0 deletions

View File

@ -2,6 +2,18 @@
<!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>[uparrow]</string>
<key>action</key>
<string>selectNextUp:</string>
</dict>
<dict>
<key>key</key>
<string>[downarrow]</string>
<key>action</key>
<string>selectNextDown:</string>
</dict>
<dict>
<key>key</key>
<string>[leftarrow]</string>

View File

@ -253,6 +253,51 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner {
NSPasteboard.general.copyObjects(selectedArticles)
}
@IBAction func selectNextUp(_ sender: Any?) {
guard let lastSelectedRow = tableView.selectedRowIndexes.last else {
return
}
let nextRowIndex = lastSelectedRow - 1
if nextRowIndex <= 0 {
tableView.scrollTo(row: 0, extraHeight: 0)
}
tableView.rs_selectRow(nextRowIndex)
let followingRowIndex = nextRowIndex - 1
if followingRowIndex < 0 {
return
}
tableView.scrollToIfNotVisable(index: followingRowIndex)
}
@IBAction func selectNextDown(_ sender: Any?) {
guard let firstSelectedRow = tableView.selectedRowIndexes.first else {
return
}
let tableMaxIndex = tableView.numberOfRows - 1
let nextRowIndex = firstSelectedRow + 1
if nextRowIndex >= tableMaxIndex {
tableView.scrollTo(row: tableMaxIndex, extraHeight: 0)
}
tableView.rs_selectRow(nextRowIndex)
let followingRowIndex = nextRowIndex + 1
if followingRowIndex > tableMaxIndex {
return
}
tableView.scrollToIfNotVisable(index: followingRowIndex)
}
func toggleReadStatusForSelectedArticles() {
// If any one of the selected articles is unread, then mark them as read.