Re: firstResponder comparison failing
Re: firstResponder comparison failing
- Subject: Re: firstResponder comparison failing
- From: Mark Dawson <email@hidden>
- Date: Fri, 09 Jun 2006 16:34:12 -0700
>Right away I am suspicious why you want to be polling your user
>interface items to see which is the first responder. That seems very
>suspect to me.
I have an NSStepper object that controls two NSTextField. To control the correct field, I have the stepper connected to my controller. The controller needs to figure out which field has focus/firstResponder inorder to operate on the correct field (and if there is no focus, which field to default to).
>Nevertheless, Apple even provides this example code
>right in the documentation:
>> Listing 1 Determining if a text field is first responder
>> if ( [[[self window] firstResponder] isKindOfClass:[NSTextView
>> class]] &&
>>
>> [window fieldEditor:NO forObject:nil] != nil ) {
>>
>> NSTextField *field = [[[self window] firstResponder]
>> delegate];
>>
>> if (field == self) {
>>
>> // do something based upon first-responder status
>>
>> }
This is somewhat simlilar to what I developed; I added an extra check to see if the field editor was a first responder, if so, then go down the path indicated.
Mark
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden