Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
698 views
in Technique[技术] by (71.8m points)

objective c - focus a NSTextField

I have a NSTextField and I want to set its content if I klick on a button and than set the cursor on this textfield at the end of the text so if someone klicks the button he could just begin to type.

Until now I use [NSTextField selectText] it selects this textfield but it selects the whole text so if someone just begins to type he'd lose all the text which alread is in the textfield.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

or even easier

[yourTextField becomeFirstResponder];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...