On 01/09/2011, at 7:05 AM, Geert-Jan Korsbø Nilsen wrote:

> Im working on a tiny app just to learn cocoa, and Im having a hard time with 
> setting FirstResponder to some NSTextFields.
> 
> When the view opens, I want the first NSTextField, clientNumber, to be 
> selected, so I trigger [clientNumber becomeFirstResponder] at the end of my 
> loadView method, but it does not select the text field.
> But when I click the button that fires the (IBAction)addToArray method, it 
> selects the right text field. Further do I have another text field, it should 
> contain integers only, so I have a crude verification for it. When the 
> content is not a int, I get a beep, just like it should, but it does not 
> select the text field.

Geert,

here's an excerpt from the documentation.  Note the last sentence.



- (BOOL)becomeFirstResponder
Return Value
Returns YES.

Discussion
If the previous first responder was not an NSTextView on the same 
NSLayoutManager as the receivingNSTextView, this method draws the selection and 
updates the insertion point if necessary.

Use the NSWindow method makeFirstResponder:, not this method, to make a text 
view the first responder. Never invoke this method 
directly._______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to