home *** CD-ROM | disk | FTP | other *** search
- 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
- From: d1pihlan@dtek.chalmers.se (Fredrik Pihlstr|m)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Reading numbers in TextEdit
- Message-ID: <C1H2Iw.2tx@news.chalmers.se>
- Date: 26 Jan 93 17:42:32 GMT
- References: <1993Jan25.210950.22383@udel.edu>
- Sender: news@news.chalmers.se
- Organization: Chalmers University of Technology, Sweden
- Lines: 39
- In-Reply-To: sethi@pokey.cis.udel.edu's message of 25 Jan 93 21:09:50 GMT
- Nntp-Posting-Host: hacke8.dtek.chalmers.se
-
- sethi@pokey.cis.udel.edu (Adarshpal S Sethi) said:
- >Nntp-Posting-Host: pokey.cis.udel.edu
-
-
- >I have a Modeless Dialog with a TextEdit field that I want
- >to use to read in a number. I would like to disable any
- >character that is not a numeric character from being entered.
- >Is there a way of doing this? I couldn't see anything in
- >IM that was helpful. In the worst case, can I get access
- >to each character that is entered in a TextEdit field, then
- >check if it is a numeric character, if not delete the
- >character from the text being entered and continue?
- >If there is a sample program available somewhere that can
- >do this, that would be great (I'm using Think C 5.0), but
- >I would appreciate any help at all, whether it is a general
- >outline of how to do this, or pointers to specific places in
- >IM.
-
- >Thanks,
-
- >Adarsh Sethi
- >sethi@udel.edu
-
- The way I implement this in my dialogs is by check for keyDown and
- autoKey events in my dialogfilter. If the character is not within the
- valid range then the filter returns True, thus telling the Dialog
- Manager that this event has been taken care of. If the character is a
- number then just return False and the manager takes care of putting
- the number in the TE.
-
- Don't know if this is the proper way to do it, but it works...
-
- Ho ho ho,
- Pihlan
- --
- ----------------------------------------------------------------------
- Fredrik Pihlstr|m d1pihlan@dtek.chalmers.se
- Tel:+46 (0)31 265 479 Snail: L. Skogsv. 25, S-433 70 Partille, Sweden
- Computer Science & Engineering, Chalmers Un of Tech, Gothenburg
-