How to program an Enter key to assign a value entered into a Text Editor Object?

When the user of the system I’m writing enters text into a Text Editor Object but fails to terminate that entry with the ENTER key, and then clicks on a button which uses that text value in a procedure, no value is assigned to the related variable. Worse still, if a value had previously been assigned, that value remains and the user doesn’t know that her new data entry has been ineffectual.

I don’t believe that I can do anything to trap the second occurrence (which is very scary) but the only way I know to trap the first is to respond to an empty value with an error message.

I’d really like to program the missing ENTER keystroke before processing the data - is there a way to do this or to achieve the same result?

Whenever there is a chance of that happening the first line of your program should be closeactiveobject (or you can use the older superobjectclose, which is equivalent).

Perhaps you are wondering why this isn’t done automatically? It’s because you can write a program that operates on the edited text, in which case you don’t want the close to happen. It’s rare, but it does happen.

Thanks Jim. Whenever I’m looking for something like this I ask myself, what would Jim have called it if it existed? I am very rarely even close :slight_smile: