Rolf Kocherhans wrote:
> Is there a way to continuously check when a user types into a field
> and allows only certain characters?
>
> Something like this:
>
> on checkForInput
> if the char is not "a,g,t,c"
> ---do nothing
> else
> remove last char in fld "fldTest"
> end checkForInput
>
> This would only allow to enter the chars a,g,t or c into a field.
Yes, one way to do this would be to check the key pressed in a keyDown
handler (the parameter sent with the keyDown message) and only pass keyDown
if that key is allowed.
> How can I check for field input only while the cursor is within the field
?
You could use the within() function to do this.
> If I can not do this I will have an idle handler running all the time.
It's always preferable not to use an idle handler (see the tip of the week
on our website).
> Is there also a way to limit the number of chars which a user can type?
The following handler should do all this. It only passes, and therefore
only allows keystrokes under all the conditions you give.
on keydown pKey
if (pKey is not in "agtc" and within(me,the mouseLoc)) \
or the num of chars in me is 10 then beep
else pass keyDown
end keydown
Cheers,
Michael
--
Michael Fisher <[EMAIL PROTECTED]> <http://www.runrev.com/>
Runtime Revolution Ltd - Power to the Developer!
Tel: +44 (0)870 747 1165 Fax: +44 (0)1639 830 707