textShouldNotEvenThinkAboutEndEditingIfItKnowsWhatIsGoodForIt
textShouldNotEvenThinkAboutEndEditingIfItKnowsWhatIsGoodForIt
- Subject: textShouldNotEvenThinkAboutEndEditingIfItKnowsWhatIsGoodForIt
- From: Graham J Lee <email@hidden>
- Date: Thu, 2 Dec 2004 16:00:26 +0000
Hi,
I have an NSTextField with attached NSNumberFormatter, such that it
will only accept integers. Further, I want these integers to lie
within the range (POLYMIN,POLYMAX) so my document controller object
contains the following delegate method:
-(BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)text
{
int n=[[text string] intValue];
if(n<POLYMIN || n>POLYMAX) return NO;
else return YES;
}
However I've noticed that if a user enters an out-of-range number and
then, rather than hitting return or tab, just presses e.g. a button,
then the method invoked by that button does run and does see the
current intValue of the field and hence crashes and burns. Now I've
just noticed the existence of NSStepper, but before I [i]dig into that
[ii]change my UI as a result, is there a way of making sure that the
NSTextField's content is *definitely* validated before it is used?
Thanks,
--
Graham Lee GPG Key ID: 01D5B9D8
UNIX Systems Manager,
Oxford Physics Practical Course
http://nextstep.sdf-eu.org 01865 273450
_______________________________________________
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