• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: firstResponder and multiple NSTextFields
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: firstResponder and multiple NSTextFields
      • From: Brad Peterson <email@hidden>
  • Prev by Date: Re: NSLayoutManager draws text garbled at end of line
  • Next by Date: Sync services and CoreData
  • Previous by thread: firstResponder and multiple NSTextFields
  • Next by thread: Re: firstResponder and multiple NSTextFields
  • Index(es):
    • Date
    • Thread