Disallow selecting group items. Fix #193.

This commit is contained in:
Brent Simmons 2017-11-19 21:01:16 -08:00
parent f885c918d2
commit 8fc7445a7a
1 changed files with 15 additions and 0 deletions

View File

@ -151,6 +151,21 @@ import RSCore
return node.isGroupItem return node.isGroupItem
} }
func outlineView(_ outlineView: NSOutlineView, selectionIndexesForProposedSelection proposedSelectionIndexes: IndexSet) -> IndexSet {
// Dont 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) { func outlineViewSelectionDidChange(_ notification: Notification) {
// TODO: support multiple selection // TODO: support multiple selection