Re: firstResponder and multiple NSTextFields
Re: firstResponder and multiple NSTextFields
- Subject: Re: firstResponder and multiple NSTextFields
- From: Erik Buck <email@hidden>
- Date: Wed, 24 Aug 2005 13:29:34 -0700 (PDT)
The firstResponder while editing a text field is typically the containing window's field editor.
See Apple's documentation and past discussions on this list about the field editor.
As it happens, while editing a text field, the delegate of the field editor is the field being edited.
You can edit your code as follows:
NSText *fieldEditor = [[licenseSheet firstResponder];
NSControl *field = nil;
if([fieldEditor respondsToSelector:@selector(delegate)])
{
field = [fieldEditor delegate];
}
if (field == txtPartialSN1)
- or-
NSText *fieldEditor = [[licenseSheet firstResponder];
int tag = -1;
if([fieldEditor respondsToSelector:@selector(delegate)])
{
tag = (NSControl *)[[fieldEditor delegate] tag];
}
if (tag == txtPartialSN1)
However, I think that is all unnecessary because I think you can set up your formatter to end editing when the correct number of digits are entered and you can set up the nextField to automatically move to the next field when editing ends. You could also use the controlTextDidEndEditing or some such notification or you could use an action with the text field. Both of these choices avoid having to perform comparisons with the field editor because the field itself is sent as the object of the notification or the sender of the action.
_______________________________________________
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