Inserting a character at the text insertion point in a field

Richmond richmondmathewson at gmail.com
Tue Apr 28 15:34:54 EDT 2015


On 28/04/15 22:06, Tore Nilsen wrote:
> I try to make a script in a field to allow only numbers or the decimal sign to be entered into the field. To block any other key is easy, but I have run into problems when I try to insert the decimal sign at the text insertion point in the field.
>
> This script only allows me to insert the decimal sign at the end of the string. I seem to be unable to find any help in the lessons on the runner web site or in the dictionary.  Does anyone have a smart solution that I can use to impress my students, and maybe help them in their preparations for their exam?
>
> on keyDown theKey
>        if theKey is a number then
>        pass keyDown
> end if
>     if theKey is "." or theKey is "," then
>        if the text of me is not empty and "." is not in me then
>           put "." after me
>        end if
>     end if
> end keyDown
>
>>
> Tore Nilsen
> _______________________________________________
>

set the text of the selectedText to "3"

Richmond.




More information about the use-livecode mailing list