In an NSTableView (Appkit), I need to colour a cell background when it is selected.
That works OK, except that the colour does not span the full cell width, nor even the text itself:
The tableView structure is very basic:
I see there is a TextCell at the end that cannot be deleted. What is this ?
And the colouring as well:
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
let p = someDataSource[row]
if let cellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Cell"), owner: self) {
(cellView as! NSTableCellView).textField?.stringValue = p
if selected[row] {
(cellView as! NSTableCellView).backgroundColor = theLightBlueColor
} else {
(cellView as! NSTableCellView).backgroundColor = .clear
}
return cellView
}
}
I've tried to change size constraints in many ways, to no avail.
For instance, I changed Layout to Autoresising :
I tried to change TableCellView size to 170 vs 144:
Or increase tableColum Width.
I have looked at what other object in the NSTableView hierarchy should be coloured without success.
Nothing works.
What am I missing ?