mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-25 01:01:21 +01:00
Add NSOutlineView extension methods: canSelectItem and selectItemAndScrollToVisible.
This commit is contained in:
parent
7ba2fe72dd
commit
ef8f508ee4
@ -159,9 +159,28 @@ public extension NSOutlineView {
|
||||
guard let item = item(atRow: row) else {
|
||||
return false
|
||||
}
|
||||
return canSelectItem(item)
|
||||
}
|
||||
|
||||
func canSelectItem(_ item: Any) -> Bool {
|
||||
|
||||
let isSelectable = delegate?.outlineView?(self, shouldSelectItem: item) ?? true
|
||||
return isSelectable
|
||||
}
|
||||
|
||||
func selectItemAndScrollToVisible(_ item: Any) {
|
||||
|
||||
guard canSelectItem(item) else {
|
||||
return
|
||||
}
|
||||
|
||||
let rowToSelect = row(forItem: item)
|
||||
guard rowToSelect != -1 else {
|
||||
return
|
||||
}
|
||||
|
||||
rs_selectRowAndScrollToVisible(rowToSelect)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user