Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSTableView how to click anywhere in the cell to edit text?

I have a very simple NSTableView hooked up via NSArrayController and bindings to my model. I would like to tweak the behaviour the of the view slightly when double clicking to edit. It seems the default behaviour for when double click editing a cell is to only open the cell for editing when the click happens on the location of text inside the cell (see below).

I would like to change the behaviour so that a double click anywhere in the cell causes editing (the green case in the image below). Any ideas? Maybe I was searching for the wrong terms but I couldn't find anything out there about this.

enter image description here

like image 809
Daniel Farrell Avatar asked Jan 29 '12 09:01

Daniel Farrell


1 Answers

Subclass NSTextFieldCell and override -hitTestForEvent:inRect:ofView: to return NSCellHitEditableTextArea regardless of where the mouse click occurred.

like image 159
Aderstedt Avatar answered Oct 15 '22 18:10

Aderstedt