private class ScrollSelectionCallback implements Runnable {
private int x = 0;
public void run() {
TextInput textInput = (TextInput)getComponent();
TextNode textNode = textInput.getTextNode();
int selectionStart = textInput.getSelectionStart();
int selectionLength = textInput.getSelectionLength();
if (x < 0) {
// Add the previous character to the selection
if (selectionStart > 0) {
selectionStart--;
selectionLength++;
}
} else {
// Add the next character to the selection
if (selectionStart + selectionLength < textNode.getCharacterCount()) {
selectionLength++;
}
}
textInput.setSelection(selectionStart, selectionLength);
}