home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22235 < prev    next >
Encoding:
Internet Message Format  |  1993-01-27  |  2.2 KB

  1. Path: sparky!uunet!pageworks.com!world!eff!sol.ctr.columbia.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sunic!chalmers.se!news.chalmers.se!dtek.chalmers.se!d1pihlan
  2. From: d1pihlan@dtek.chalmers.se (Fredrik Pihlstr|m)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Reading numbers in TextEdit
  5. Message-ID: <C1H2Iw.2tx@news.chalmers.se>
  6. Date: 26 Jan 93 17:42:32 GMT
  7. References: <1993Jan25.210950.22383@udel.edu>
  8. Sender: news@news.chalmers.se
  9. Organization: Chalmers University of Technology, Sweden
  10. Lines: 39
  11. In-Reply-To: sethi@pokey.cis.udel.edu's message of 25 Jan 93 21:09:50 GMT
  12. Nntp-Posting-Host: hacke8.dtek.chalmers.se
  13.  
  14. sethi@pokey.cis.udel.edu (Adarshpal S Sethi) said:
  15. >Nntp-Posting-Host: pokey.cis.udel.edu
  16.  
  17.  
  18. >I have a Modeless Dialog with a TextEdit field that I want
  19. >to use to read in a number. I would like to disable any
  20. >character that is not a numeric character from being entered.
  21. >Is there a way of doing this? I couldn't see anything in
  22. >IM that was helpful. In the worst case, can I get access
  23. >to each character that is entered in a TextEdit field, then
  24. >check if it is a numeric character, if not delete the
  25. >character from the text being entered and continue?
  26. >If there is a sample program available somewhere that can
  27. >do this, that would be great (I'm using Think C 5.0), but
  28. >I would appreciate any help at all, whether it is a general
  29. >outline of how to do this, or pointers to specific places in
  30. >IM.
  31.  
  32. >Thanks,
  33.  
  34. >Adarsh Sethi
  35. >sethi@udel.edu
  36.  
  37. The way I implement this in my dialogs is by check for keyDown and
  38. autoKey events in my dialogfilter. If the character is not within the
  39. valid range then the filter returns True, thus telling the Dialog
  40. Manager that this event has been taken care of. If the character is a
  41. number then just return False and the manager takes care of putting
  42. the number in the TE.
  43.  
  44. Don't know if this is the proper way to do it, but it works...
  45.  
  46. Ho ho ho,
  47. Pihlan
  48. --
  49. ----------------------------------------------------------------------
  50. Fredrik Pihlstr|m                            d1pihlan@dtek.chalmers.se
  51. Tel:+46 (0)31 265 479  Snail: L. Skogsv. 25, S-433 70 Partille, Sweden
  52.    Computer Science & Engineering, Chalmers Un of Tech, Gothenburg
  53.