Action in TextFields
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.