myInput.setText(myInput.getText().replace(myInput.getSelectionStart(), myInput.getSelectionEnd(), myText));
myInput.setSelection(myInput.getSelectionStart() + myText.length(), myInput.getSelectionEnd() + myText.length())
I ask because I think this code is much longer than it should be. Is there something shorter like myInput.insertTextAtCursor(myText), or is it the way everyone does it?
source
share