TextField and SearchField ignore a caret or selection set immediately after assigning Text
- Status
- Fixed
- Fixed in
- v26.10.4
- Area
- desktop
- Source discussion
- https://forum.objo.dev/d/1372-bug-textfield-desktop
- Last updated
- 2026-10-30
Upvotes
0 upvotes
Uses your Objo forum account.
Public summary
In a Desktop project, assigning Text to a TextField or SearchField and then setting SelectionStart (or SelectionLength / SelectedText) in the same handler does not position the caret or selection as requested. The new text appears, but the caret stays at the start of the field.
Reproduction with a TextField dropped on a window:
Event Opening() # TextField1
Me.Text = "Hello"
Me.SelectionStart = 5
Me.SetFocus()
End Event
Expected: the field shows "Hello" with focus and the caret after the final character.
Actual: the field shows "Hello" with focus, but the caret is at position 0.
The Text assignment is applied to the control slightly later than the selection change, so the requested position is clamped against the previous (empty) text. For the same reason, reading Text immediately after assigning it can return the previous value. TextArea is not affected, and SetFocus() is not involved: the fault reproduces without it.