Path: utzoo!attcan!uunet!lll-winken!ames!elroy!usc!orion.cf.uci.edu!uci-ics!milne From: milne@ics.uci.edu (Alastair Milne) Newsgroups: comp.sys.mac.programmer Subject: Re: Who has hacked numeric TEdit?. Message-ID: <16413@paris.ics.uci.edu> Date: 2 Jun 89 02:54:16 GMT References: <1076@mailrus.cc.umich.edu> <11722@well.UUCP> Sender: news@paris.ics.uci.edu Reply-To: Alastair Milne Distribution: na Organization: Educational Technology Center, Dept. of ICS, UC Irvine Lines: 32 odawa@well.UUCP (Michael Odawa) writes >In article <1076@mailrus.cc.umich.edu> cash@csmil.umich.edu (Howard Cash) writes: >> Who is willing to part with the code for an editable text item >> that only accepts valid numbers (real or integer)? > >You can intercept the keystrokes in the FilterProc you call with >ModalDialog. Then peek at every key event as it comes in. If it's not >a digit, change the event into a nullEvent and mark it as handled: I have a small problem with that approach: the user has no way of knowing why his keystrokes aren't registering. There is nothing here to alert the user that only digits (and signs, and ".", etc.) are to be used. I think an alert is necessary for this, either right at the keystroke (perhaps the filterproc could show it, before turning the event into a null); but I don't know whether filterproc's are allowed to fire up alerts or dialogs. The other way, of course, is simply to let the user finish and enter the text, then give the alert and restart the entry if the format is not completely numeric. Advantages: simple slips of the finger are not rewarded with a whole alert, and the user gets the chance to edit and modfy as s/he sees fit. Now for the nasty part. I assuming we've been thinking so far about the entry of integers. What about real numbers? I may just have missed it, but I don't recall seeing any standards in I-M for real number format (beyond the settings of components that differ between countries.) Having worked on CAI material for some years, where such entry has to be made very tolerant for students who've never used a computer before, I can attest the number of difficulties to consider. Are there any standards for this? Alastair Milne