Avoid the insertion character in a TextEdit field

This bother me since Methuselah (Mathusalem) was a kid (no offence here people).

This dates from some days (weeks ?) and needs an explanation (from my point of view). I needed it minutes ago, and I wanted to share it here sine the question arise sometimes.

When you have a TextEdit Control (TextField or TextArea) in a Window, the first one (the one with the lower Control ID value) have the focus and I had all kinds of trouble removing it.

When the case happens:
• Go to the Window Editor,
• Select all TextEdit Controls (or just the one you do not want it to get the Focus),
• Set the Properties pane,
• Click in the preferences icons (at the right of the ID icon, above the Properties pane),
• Click in the “Focus Control” Boolean property selector Tab Stop to set it OFF.
• Done.

Run the project, display the window and enjoy.

Changing the Control ID of the TextEdit Class does not removes that focus, it just send it to the Control with the smaller Control ID.

Nota: I do not know if this have a side effect: I do not have to type text in these.


You can use the Auto Adjust Tab Order button or the Show Tab Order button in the IDE

For what it’s worth, it’s been discussed before, and the first TextField/Area on the Window having focus when it opens is expected behavior from the framework.

Note that if you turn off TabStop, the user can’t tab to the text field. I can’t imagine anyone ever hearing the end of those complaints should they do that in commercially available software.

You could also use SetFocus in order to make the right control active. :wink:

Stphane and Paul:
Did you check before answering ?

I have cases, as I wrote earlier, where the user do not have to type into the TextEdit Controls (and they are read only) online contextual help for example.

I probably misunderstand you completely, but I don’t get a focus on any field with the tabstop off.

Tried running it with readonly on and readonly off on all the fields.
When I run the program, neither of the textfields gets the focus, as expected.

Emile, there are still accessibility reasons to have focus rings on read only text fields.