Fernando Mata
Fernando Mata

Reputation: 492

How to reset selection to a certain NSTextField?

I've a form with five NSTextFields. After the user clicks the "Add" button I would like that the selection goes to the first text field so the user can start typing info again.

Is there a way to do that? Closing an reopening the view doesn't work for this.

Upvotes: 1

Views: 72

Answers (1)

Undo
Undo

Reputation: 25697

Make the text field that you want the focus to shift to the 'first responder'. You tell the window to do this:

[[textFieldToEdit window] makeFirstResponder:textFieldToEdit];

Upvotes: 2

Related Questions