TextField behavior?

Greetings, folks -

Well, I am dragging myself, kicking and screaming, into the “modern era” with 2019R3. Previous version I had used was maybe 2017R??. I’ve been used to, over the years, of using KeyUp events in TextFields, to screen and limit entries into TextFields. You could do this by managing the return value from the event handlers, which would then block or process that key entry into the field’s text.

The new TextFields no longer have that behavior. The KeyUp event no longer returns anything. So, what is the expected method to manage the key entries? I tried the mask property, and that was a total bust. For example, I have a field that is pre-filled with the year from a DateTime object and I use a mask of “####”. When I do that, the field’s text is not editable, it does not even allow a character to be deleted or a character to be selected and typed over.

Right now, I am sidestepping that with a popup menu but that is less than desirable when you need to select one of 31 entries (day of the month) or one of 60 entries (minutes).

Suggestions, strategies, etc, are gratefully accepted.

Many thanks
Jim Wagner
Oregon Research Electronics

The LR says in .KeyDown for API2 (your Xojo version):

TextField and TextArea
Returning [True](http://docs.xojo.com/True)means the key is intercepted, preventing the key from actually reaching the control at all. This would be useful if you want to override the behavior of the tab key for example. Returning [False](http://docs.xojo.com/False)means the key reaches the control.

Sorry, I was sure that the LR had nothing about a return value when I looked at it last night. Apologize for the noise!

Jim

Sometimes, a second read (hours later) allow my eye to see what is in the LR. For some mysterious reason, sometimes I do read only parts (and left an important part). :wink:

Happy to help.

I found the source of my confusion. I had THOUGHT that the KeyUp event would be the proper one to trap. That event has no return value. Had I thought a bit more carefully, I would have realized that KeyDown is, in fact, the logically correct one and, that event does have a return value that controls whether the key entry is processed further by the system. Mea culpa!

Jim

1 Like