Mikk Rätsep
Mikk Rätsep

Reputation: 512

Single click to edit NSTextField

I'm sorry to ask this again, I've looked over all the related questions here, but none seems to help me (or I just can't get it).

Atm, I have an NSTextField that operates like every other of its kind, but it needs double-to-triple click to select all of it's content for editing (double selects one word, triple - all of them).

I unfortunately need this to work in a way, that when a user clicks on it once, all the text gets selected, so one can start typing a new thing instantly.

Upvotes: 2

Views: 1856

Answers (1)

Michael Dautermann
Michael Dautermann

Reputation: 89509

Basically you should follow the solutions in this duplicate question

and once you are in your own derived -(void) mouseDown: (NSEvent *) theEvent method, simply select all the text by doing calls to either

[NSTextField selectText:]

or

[NSText setSelectedRange:]

Upvotes: 3

Related Questions