🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
2 messages
2 total messages Started by Nader Sahyouni Wed, 05 Aug 1992 19:18
Text Object/FormCell use in IB question
#456
Author: Nader Sahyouni
Date: Wed, 05 Aug 1992 19:18
25 lines
1542 bytes
Using some of the wisdom gleaned from an earlier thread,
"Re: Formcell behaviour", I attempted a test program where
I pulled in five FormCell matrices from the palette.

I connected all their text delegates to one object containing
a textDidEnd:anObject whyEnd:... method. Within this method
I can read whatever was typed in into any of the cells as 
soon as first responder changes. Works thus far, GREAT! 

BUT, since all these matrices are using the same textObject
according to the manual, how can I tell which cell in which
matrix was just modified. I can message [anObject substring...]
to get what was typed in, but I can't tell which cell the info
is coming from. There must be a way, I'm having a bad day, and
I just don't see it. 

The only other alternative I see is to build a separate file
/separate object to be a specific delegate for a given
field. That would make lots of files for a simple electronic
form app. That does not seem right, although it may very well be.

Thanks in advance,

xns@nwu.edu
Re: Text Object/FormCell use in IB question
#463
Author: Linus Upson
Date: Thu, 06 Aug 1992 02:00
37 lines
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads