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

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

  •  24-06-2022
  •  | 
  •  

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?

有帮助吗?

解决方案

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];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top