Field listener

Ken Ray kray at
Sun Sep 10 14:14:00 EDT 2006

On 9/10/06 11:17 AM, "Trevor Hopkins" <tjhopkins224 at> 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:
Email: kray at

More information about the Use-livecode mailing list