Problem with Editable Fields

David Burgun dburgun at dsl.pipex.com
Mon Jul 18 11:32:18 EDT 2005


Hi,

I have the a number of fields in a card that have to be range 
checked, to do this i have the following code:

on openField
set the cpSaveTextOfMe to the text of me
end openField

on closeField
if (the text of me < 0) or (the text of me > 999) then
   set the text of me to the cpSaveTextOfMe of me
   select the text of me
   beep
end closeField


There is also a "Done" Button that has this script:

on mouseUp
save this stack
close this stack
end mouseUp

If I enter an invalid number and then click in another field, I get 
beep and the contents of the field are restored and all is well. 
However, if I enter an invalid number and then click the "Done" 
button, it looks like the "mouseUp" handler is run BEFORE the 
"closeField" handler. Since the value stored in the stack is the 
invalid data. Is this the correct action? If so, what is the best way 
to make this work so that bad values are not saved in the stack. I 
really don't want to have to validate all fields from the "Done" and 
other buttons on the card.

Thanks in Advance
Dave



More information about the use-livecode mailing list