• 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
NSTextField controlTextDidEndEditing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextField controlTextDidEndEditing


  • Subject: NSTextField controlTextDidEndEditing
  • From: Ulai Beekam <email@hidden>
  • Date: Sat, 6 Mar 2010 01:00:50 +0000
  • Importance: Normal

I have a delegate of NSTextField that uses the controlTextDidEndEditing: method to do some stuff when the editing has finished.

However, there are (as far as I can imagine) two types of possible scenarios under which the editing finishes: 1) the user hits return. in this case, the focus stays on the text field. 2) the user presses tab or clicks someplace else, in which case the text field loses focus.

My question is: What is the proper way to know *within the controlTextDidEndEditing: delegate method* which of the two scenarios occurred (or will occur? i suppose it has already occurred since it's a "Did" method)?

This is how I'm currently doing it, and it is not working properly:

- (void)controlTextDidEndEditing:(NSNotification *)aNotification
{
  NSTextField *textField = [aNotification object];
  NSTextView *fieldEditor = [[aNotification userInfo] objectForKey:@"NSFieldEditor"];
    if ([[textField window] firstResponder] == fieldEditor)
    NSLog(@"focus lost");
  else
    NSLog(@"focus retained");
}

This works only in that if the user *clicks* outside the text field, "focus lost" is printed, and if the user hits return, "focus retained" is printed. However, this *fails* when I tab out of the text field, in which case "focus retained" is printed, which obviously indicated that my way of doing this sucks.

So I'm all out of luck. Any ideas?

Thanks, U.




_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
https://signup.live.com/signup.aspx?id=60969_______________________________________________

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

  • Follow-Ups:
    • Re: NSTextField controlTextDidEndEditing
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: Re: [NSTableview] can't make selected text stay black
  • Next by Date: Re: NSTextField controlTextDidEndEditing
  • Previous by thread: Re: [NSTableview] can't make selected text stay black
  • Next by thread: Re: NSTextField controlTextDidEndEditing
  • Index(es):
    • Date
    • Thread