Problem with Editable Fields

Eric Chatonet eric.chatonet at sosmartsoftware.com
Mon Jul 18 11:42:01 EDT 2005


Hi Dave,

May be another approach, more ergonomic, could help you:
Just allow numbers to be typed into your field with a generic handler  
like the following:

on keyDown pKey
   if pKey is an integer and the number of chars of target < 3 then  
pass keyDown
end keyDown

It's only to get you started: you will find you have probably to  
build a rawKeyDown handler to be more precise and manage the current  
selection (if the user selects a portion and wants to type in).

Best Regards from Paris,

Eric Chatonet.

Le 18 juil. 05 à 17:32, David Burgun a écrit :

> 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.


----------------------------------------------------------------
So Smart Software

For institutions, companies and associations
Built-to-order applications: management, multimedia, internet, etc.
Windows, Mac OS and Linux... With the French touch

Free plugins and tutorials on my website
----------------------------------------------------------------
Web site        http://www.sosmartsoftware.com/
Email        eric.chatonet at sosmartsoftware.com/
Phone        33 (0)1 43 31 77 62
Mobile        33 (0)6 20 74 50 86
----------------------------------------------------------------




More information about the use-livecode mailing list