How to set the caret/cursor at the beginning of the selected text instead of at the end?
Posted on 2005-04-11
I have a textbox in which commands are typed. Using the left and right arrows I want to allow the user to select the text from the cursor up to the end of the text.
This functionality equals the shift + left/right arrow standard functionality, but I want to be able to do it without the shift pressed, because I want to make sure the user cannot just place the cursor anywhere in the text.
The problem is that when you set a selection, either using selectionstart and selectionlength or select(start,length), the caret/cursor is always positioned at the end of the selection and no matter what I do, I cannot get it at the beginning of the selection, where I want it to be.
There must be a way since the standard functionality using shift left/right arrow works just fine, but I don't know how.