Article View: comp.sys.next.programmer
Article #463Re: Text Object/FormCell use in IB question
From: Linus Upson
Date: Thu, 06 Aug 1992 02:00
Date: Thu, 06 Aug 1992 02:00
37 lines
2427 bytes
2427 bytes
I attempted implement text field validation as in the NeXT example: /NextDeveloper/Examples/SortingInAction/SortController.m using the textWillEnd: delegate method. Unfortunately, this does not behave quite properly. If a value larger than 5000 is entered into a particular cell, it attempts to clip the entry down to 5000: - (BOOL)textWillEnd:textObject .. form = [textObject delegate]; .. if (value>5000) [[form selectedCell] setIntValue:5000]; .. When the user enters 5001 in the cell and clicks to another cell with the mouse, the code behaves properly and the 5001 is replaced with 5000. If, on the other hand, the user terminates input to the cell by pressing return or tab, the 5001 is momentarily replaced by 5000, but a split second later 5001 reappears. If you return to the offending cell (by repeatedly pressing return, tab, or clicking there), then click to another cell the 5001 is replaced by 5000 (even though you hands never touched the keyboard). By returning YES from textDidChange: you can block the user from moving on until they have entered something valid, but it is often nice to give them a hint as to the range of valid values by clipping the input. Also, for a set of related text fields, an entry in one field might affect the values in others. /NextDeveloper/Examples/Mandelbrot/MandelControl.m attempts to do this with a textDidChange: method as the target of the form (the comment says it is called as a delegate of the form, but a look in IB reveals that it is the target, and no text delegate is set), but it doesn't work either (the message is not sent if the user clicks away). My question is: What is the best way to implement text field validation? Linus Upson lupson@geom.umn.edu
Technical Details
Message-ID:
<1992Aug6.020020.15272@news2.cis.umn.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!darwin.sura.net!mips!swrinde!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!news.cs.indiana.edu!umn.edu!newsReferences:
<1992Aug5.191837.24169@news.acns.nwu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!darwin.sura.net!mips!swrinde!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!news.cs.indiana.edu!umn.edu!news From: lupson@descartes (Linus Upson) Newsgroups: comp.sys.next.programmer Subject: Re: Text Object/FormCell use in IB question Keywords: text Message-ID: <1992Aug6.020020.15272@news2.cis.umn.edu> Date: 6 Aug 92 02:00:20 GMT References: <1992Aug5.191837.24169@news.acns.nwu.edu> Sender: news@news2.cis.umn.edu (Usenet News Administration) Distribution: na Organization: University of Minnesota Lines: 37 Nntp-Posting-Host: descartes.geom.umn.edu