• 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
What's the best way to limit input on an NSTextField to numbers only? (newbie)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What's the best way to limit input on an NSTextField to numbers only? (newbie)


  • Subject: What's the best way to limit input on an NSTextField to numbers only? (newbie)
  • From: Rob Frohne <email@hidden>
  • Date: Sun, 1 Sep 2002 22:58:21 -0700

Hi All,

I'd like to limit input into my NSMatrix of NSTextFields to be numbers only, things like 3.2e5, or 5.5 or 9.99. I got a delegate that gets run when the NSTextFields change, but the NSString I get isn't quite as simple to process as just the individual keys that are being typed. I've looked at NSScanner, and it looks like that might have some merit. Is that the best way to handle this kind of thing?

Thanks,

Rob

P.S. Here is my present delegate:

- (void)controlTextDidChange:(NSNotification*)aNotification
{
// if (([[displayMatrix selectedCell] stringValue] < '1') || ([[displayMatrix selectedCell] stringValue] > '9')) // This doesn't work because we are getting a whole string instead of just an ASCII char.
{
NSBeep();
}
}

--
Rob Frohne, Ph.D., P.E.
E.F. Cross School of Engineering
Walla Walla College
http://www.wwc.edu/~frohro/
_______________________________________________
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: What's the best way to limit input on an NSTextField to numbers only? (newbie)
      • From: Ondra Cada <email@hidden>
    • Re: What's the best way to limit input on an NSTextField to numbers only? (newbie)
      • From: Scott Anguish <email@hidden>
  • Prev by Date: [ANN] CodeSearch web search of Open Source Projects
  • Next by Date: Re: What's the best way to limit input on an NSTextField to numbers only? (newbie)
  • Previous by thread: [ANN] CodeSearch web search of Open Source Projects
  • Next by thread: Re: What's the best way to limit input on an NSTextField to numbers only? (newbie)
  • Index(es):
    • Date
    • Thread