Re: Setting text field as first responder in an NSView
Re: Setting text field as first responder in an NSView
- Subject: Re: Setting text field as first responder in an NSView
- From: Kyle Sluder <email@hidden>
- Date: Wed, 01 Jun 2011 10:51:00 -0700
On Wed, Jun 1, 2011 at 9:15 AM, Eric Williams <email@hidden> wrote:
> Probably fundamental but I haven't got my head straight on this.
>
> Xcode 4.0.2
> OS X 10.6.7
>
> I have an app that is a single window that I load NSView elements over the course of the life of the app.
>
> I want to set the first responder for the window to be a text field in the NSView after the view is loaded, so that a user can immediately start typing into the field.
You actually want to use initialFirstResponder here. You can wire up
the window's initialFirstResponder outlet in IB to your text field,
and it will do the right thing.
In the general case (where you want to set first responder sometime
*after* window loading) use -[NSWindow makeFirstRepsonder:].
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden