Limiting text input in a text entry field

Klaus Major klaus at major-k.de
Sun Aug 17 07:42:51 EDT 2008


Hi Neil,

> Hi!
>
> This should be a straightforward thing but I can only partially get  
> it working.
> I'm trying to limit a text fields input to only numbers and integers -
> I can get numbers only by using:
>
> on keyDown theKey
>  if theKey is not a number then beep
>  else pass keyDown
> end keyDown
>
> but I can't get it to accept integers, even if I specify 'an  
> integer' in above.
>
> I think I'm missing something simple!

I think you need something like:

on keyDown theKey
  if theKey is not in ".0123456789"
     then beep
   else
      pass keyDown
   end if
end keyDown

> Cheers
> Neil

Best

Klaus Major
klaus at major-k.de
http://www.major-k.de





More information about the use-livecode mailing list