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

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


  • Follow-Ups:
    • Re: textShouldNotEvenThinkAboutEndEditingIfItKnowsWhatIsGoodForIt
      • From: Scott Stevenson <email@hidden>
    • Re: textShouldNotEvenThinkAboutEndEditingIfItKnowsWhatIsGoodForIt
      • From: j o a r <email@hidden>
  • Prev by Date: [solved]: NSTimer won't fire.
  • Next by Date: Re: textShouldNotEvenThinkAboutEndEditingIfItKnowsWhatIsGoodForIt
  • Previous by thread: Re: Event loop
  • Next by thread: Re: textShouldNotEvenThinkAboutEndEditingIfItKnowsWhatIsGoodForIt
  • Index(es):
    • Date
    • Thread