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 {
|
guard let item = item(atRow: row) else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
return canSelectItem(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
func canSelectItem(_ item: Any) -> Bool {
|
||||||
|
|
||||||
let isSelectable = delegate?.outlineView?(self, shouldSelectItem: item) ?? true
|
let isSelectable = delegate?.outlineView?(self, shouldSelectItem: item) ?? true
|
||||||
return isSelectable
|
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