From 8fc7445a7a68dbc869d957bba6a5c75bf477f619 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 19 Nov 2017 21:01:16 -0800 Subject: [PATCH] Disallow selecting group items. Fix #193. --- .../Sidebar/SidebarViewController.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Evergreen/MainWindow/Sidebar/SidebarViewController.swift b/Evergreen/MainWindow/Sidebar/SidebarViewController.swift index e22cfae7a..38a7c3ec3 100644 --- a/Evergreen/MainWindow/Sidebar/SidebarViewController.swift +++ b/Evergreen/MainWindow/Sidebar/SidebarViewController.swift @@ -151,6 +151,21 @@ import RSCore return node.isGroupItem } + func outlineView(_ outlineView: NSOutlineView, selectionIndexesForProposedSelection proposedSelectionIndexes: IndexSet) -> IndexSet { + + // Don’t allow selecting group items. + // If any index in IndexSet contains a group item, + // return the current selection (not a modified version of the proposed selection). + + for index in proposedSelectionIndexes { + if let node = nodeForRow(index), node.isGroupItem { + return outlineView.selectedRowIndexes + } + } + + return proposedSelectionIndexes + } + func outlineViewSelectionDidChange(_ notification: Notification) { // TODO: support multiple selection