So, then another challenge for either of you...
After the field has content, then I try to edit the field by selecting/highlighting the characters in the field using the mouse, it does not allow me to type in a new number. I have to hit delete or backspace. Is there a way to take that into consideration?
Hi again.
If you select a char in the field, and then try to add another number, the very nature of the handler prevents this; it thinks you want a three digit entry, which is forbidden. If you delete the second char, and then type a number, assuming it is within range, the field accepts that entry. If delete char 1, move the cursor to the right, and key a number, the field will accept it, assuming as always it is in range.
If you highlight the entire text, again any new keystroke would be seen as trying to enter a three digit number. So the latest kluge would be:
Code: Select all
on KeyDown tKey
if tKey = "-" and "-" is not in me then put "-" into me
if me & tKey >= -20 and me & tKey <= 20 then put tkey after me
if the length of the selection = the length of me then -detects when all chars are selected
put "" into me
if tKey = "-" and "-" is not in me then put "-" into me
if me & tKey >= -20 and me & tKey <= 20 then put tkey after me
end if
end KeyDown
Just adorable, no?
Ahem.
Just so you know, there is not much room left in all this to accommodate yet more gadgetry. And I do not think it worthwhile to place the working (duplicated) snippet into its own handler.
Craig