Re: textShouldNotEvenThinkAboutEndEditingIfItKnowsWhatIsGoodForIt
Re: textShouldNotEvenThinkAboutEndEditingIfItKnowsWhatIsGoodForIt
- Subject: Re: textShouldNotEvenThinkAboutEndEditingIfItKnowsWhatIsGoodForIt
- From: j o a r <email@hidden>
- Date: Thu, 2 Dec 2004 17:14:25 +0100
Have you thought about / tried using a formatter (NSFormatter)?
j o a r
On 2004-12-02, at 17.00, Graham J Lee wrote:
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?
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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