• 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
Action in TextFields
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Action in TextFields


  • Subject: Action in TextFields
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Sun, 22 Jun 2003 08:24:49 +0200

I have a window with a NSTextField and some other NSControl.

When the user enters text in the text field and hits return, the action method is called.
But when the user clicks on some other NSControl the text field action method gets called again. This annoys me.
Currently I do:

- (IBAction)textEntered:(id)sender;
{
NSString *currentTextString = [ sender stringValue ] ;

if ( [ currentTextString isEqualToString: previousTextString ] )
{
// this is probably the case where the user clicked some other NSControl
// but could also be that the user really entered the same text again
// ignore this
return ;
};

[ previousTextString release ] ;
previousTextString = [ currentTextString retain ] ;

// now do something with currentTextString
....
}

This works ok for me because, if the user enters the same string twice, I can savely ignore it.

But I have the feeling that this is not the correct way to distinguish between "return entered in text field" and "clicked in some other control".

Could someone please point me in the right direction?

Gerriet.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Action in TextFields
      • From: Dustin Voss <email@hidden>
  • Prev by Date: Hundreds of errors fixed
  • Next by Date: Navigating property lists using paths?
  • Previous by thread: Hundreds of errors fixed
  • Next by thread: Re: Action in TextFields
  • Index(es):
    • Date
    • Thread