How exactly can you find the position of the caret in a TextField? There’s no obvious
CaretPosition property or
GetCaret method; what’s a developer to do?
The answer is sneaky, but obvious: use the
SelectionStart property. This might seem unintuitive, as there is no selection; but in terms of properties,
SelectionStart has the caret position, and
SelectionLength will be zero.
And this makes sense even when there is a selection.
Sneaky. But obvious once you think about it.