If I call text->setHighlightedRegion ({3, 5}); then the TextEditor puts the caret at 3. If I move the caret after, it deselects. If I set the caret position first, it gets moved. I can obviously drag select to get it how I want, but I can’t find a way to do it programatically since moveCaretTo is private. Any ideas?
You can move the caret by calling setHighlightedRegion with an empty range, e.g. {3, 3}.
The textEditor will attempt to leave the caret in a sensible position whenever the selection changes. If you have a range selected, and then select a new range, the cursor will be placed at whichever end of the range moved. If both ends moved, then the cursor will be placed at the end of the new selection.
As a result, calling setHighlightedRegion with {3, 3} then {3, 5} will leave the caret at position 5.
That does it, thanks.
