I am developing an application in cocoa which needs to select an item by clicking a check box inside a NSTableview.I need to select the cell without highlighting the row of tabl开发者_如何学JAVAe view Is it possible to do this... Thanks in advance
NSTableView
has a method called setSelectionHighlightStyle:
to which you can send NSTableViewSelectionHighlightStyleNone
as an option and it will not show a highlight.
So, in awakeFromNib:
or similar:
[tableView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];
Normally, only selectable or selected cells can be tracked; checkboxes need tracking in order to be checked/unchecked.
But it may be possible to do what you want by using the NSTableView's delegate: the tableView:shouldTrackCell:forTableColumn:row:
method can be used to allow the tracking of non-selectable or non-selected cells.
NSTableview Has method to set selection HighlightStyle
Add below line in 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
}
Why not set the relevant Boolean property in the underlying model? If you're using Bindings, the table view should pick up the change automatically; if not, you can tell the table view to reload that row.
精彩评论