Daniel Farrell
Daniel Farrell

Reputation: 9740

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

Upvotes: 8

Views: 890

Answers (1)

Aderstedt
Aderstedt

Reputation: 6518

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

Upvotes: 3

Related Questions