NSTableview Highlight Color

I am developing an application in cocoa that needs to select an item by clicking the checkbox inside NSTableview. I need to select a cell without highlighting the table row. Can this be done ... Thanks in advance

+4
source share
4 answers

NSTableView has a method called setSelectionHighlightStyle: to which you can send NSTableViewSelectionHighlightStyleNone as an option and it will not display the selection.

So, in awakeFromNib: or similar:

[tableView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];

+18
source

Normally, only selectable or selected cells can be tracked; flags must be tracked so that they can be checked / unchecked.

But it may be possible to do what you want using the NSTableView : tableView:shouldTrackCell:forTableColumn:row: delegate can be used to track unselected or unselected cells.

+2
source

NSTableview There is a method for selecting HighlightStyle selection

Add the line below to your tableivew method:

 func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { let cell:customCell = tableView.make(withIdentifier: "customCell", owner: self) as! customCell tableview.selectionHighlightStyle = .none } 
+1
source

Why not set the appropriate Boolean property in the base model? If you use Bindings, the table view should automatically receive the changes; if not, you can say that the table view reloads this row.

0
source

All Articles