I’m having a real noodle baker at the moment with a
combo box and a text field.
I am creating a text editor to apply css styles to text, so a
portion of the text is selected in the text field, the combo box is
then used to run some code on the selected text, the end result
needs to be focus returns to the text field after the selection is
made from the combo box and the original text highlighted as it was
before the combo box came into play.
The problem I am tearing my hair out over is, even though I
use setSelection() to highlight the text again, (which you
momentarily see it selected) something sets the getBeginIndex() and
getEndIndex() to zero, not once, but constantly. The text becomes
unelectable as the cursor always resets back to (0,0).
If you click outside the text field and back in it again,
selecting the text becomes normal again.
I’ve attached a really simple version of the code
– if you fancy testing it – an input field with the
name of “input” and a combo of “styles_DD”
with random filled entries will do the trick.