Code:
/** * This is the entry point method. */ @Override public void onModuleLoad() { DynamicForm form = new DynamicForm(); final TextItem textItem = new TextItem("textItem", "textItem"); form.setItems(textItem); textItem.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { String value = textItem.getValue().toString(); if (value.length() > 5) { textItem.setSelectionRange(3, 3); System.out.println(textItem.getSelectionRange()[0]); //printed true position but //on screen, caret is always end of the text } } }); form.draw(); }
tested on Hosted Mode and Normal Browser
browsers: chrome, firefox. OS: UBUNTU, Windows7
Expected: Set cursor position to 3 when value's length greater than 5 but caret is always end of the text