How to make NSTableView cells un-selectable, but still have NStextField in the cells editable

StackOverflow https://stackoverflow.com/questions/18198289

  •  24-06-2022
  •  | 
  •  

Question

I am using a view based NSTableview. Now that view has an instance of NSTextField which i want to be selectable. But the rows of the table view should not be selectable(This is done using the delegate method - tableView:shouldSelectRow: which always returns 'NO'.)

I am able to copy text from textField only when i make the table rows selectable as well. Is there any way to keep only the NSTextField selectable without making the table rows selectable too?

Was it helpful?

Solution

Put this code in your awakeFromNib method or where ever it is applicable to your code. Your NSTableView will be not selectable, but your text fields will be editable.

[myTableView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top