firstResponder and multiple NSTextFields
firstResponder and multiple NSTextFields
- Subject: firstResponder and multiple NSTextFields
- From: Brad Peterson <email@hidden>
- Date: Wed, 24 Aug 2005 12:47:31 -0700 (PDT)
Hi all,
I've got a panel wherein users enter a multi-part
serial number and I'm trying to simplify the process
for them a bit.
As part of that goal, I'd like to have our
registration boxes work a bit more like the one you
see when you install Office, where you can enter one
part of the serial number at a time, with the focus
automatically being set to the next NSTextView when
the right number of characters has been entered.
I've set up an NSFormatter to check the length and
then tell the controller to forward the focus to the
next NSTextView. The NSFormatter is working just fine
and sends the correct message to the controller.
The controller, however, seems very confused.
I'd originally tried:
NSControl *field = (NSControl *)[licenseSheet
firstResponder];
if (field == txtPartialSN1)
but that test always failed. If I did an NSLog of
[field className] it was clearly NSTextView... So, I
tried a slightly different approach, setting the tag
values of each of the serial number text fields:
NSControl *field = (NSControl *)[licenseSheet
firstResponder];
if ([field tag] == 1)
[licenseSheet makeFirstResponder: txtPartialSN2];
Here's where it gets weirder - the [field tag] value
is always -1. Now I'm really confused.
Can anyone offer insight on this? My guess would be
that it has something to do with objects created in
the nib versus at run-time, but I'm not well-versed
enough in that topic to figure it out.
Any help would be appreciated.
Thank you.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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