Field listener

Ken Ray kray at sonsothunder.com
Sun Sep 10 13:14:00 CDT 2006


On 9/10/06 11:17 AM, "Trevor Hopkins" <tjhopkins224 at hotmail.com> wrote:

> I'm trying to build a form whose "submit" button only becomes enabled after
> text is present in a specific field (and likewise when that field is blank,
> the "submit" button returns to disabled status). Does anyone know of a
> painless way to do this? I'd also like the user to be able to hit return
> from within that field and have the "submit" button entered. Right now, it
> seems, the return key must be hit twice in order to first exit the field and
> then select "submit".

The easiest way IMHO is to put this script in the field:

on rawKeyUp
  set the enabled of btn "Submit" to (me is not empty)
end rawKeyUp

on returnInField
  click at loc of btn "Submit"
end returnInField

Now what this will do is not allow returns in the text field; i.e. any
returns hit in the field will trigger the Submit button. And by testing the
contents of the field when the keystroke has completed, we can determine
whether to enable or disable the Submit button.

Will this work for you?

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list