Is there any way by which, i can set the cursor position to end of string in listgird textbox. Example : Enter website name, once user click on cell of listgird its will display 'http://' now i want that my cursor position to the end of string.>
Asked
Active
Viewed 1,190 times
0

Reddy
- 65
- 1
- 10
-
Have you looked at this? http://stackoverflow.com/questions/511088/use-javascript-to-place-cursor-at-end-of-text-in-text-input-element – spg Dec 10 '13 at 14:31
-
@Reddy The question is related to GWT or SmartGWT? – RAS Dec 11 '13 at 05:34
-
@RAS related to SmartGWT – Reddy Dec 12 '13 at 06:57
-
@Reddy I don't think there's any such built-in functionality. But let's see for some more answers. – RAS Dec 12 '13 at 07:14
1 Answers
1
it is quite easy:
TextBox yourBox = new TextBox();
root.add(yourBox);
yourBox.setValue("AMSTERDAM");
yourBox.setFocus(true);
yourBox.setCursorPos(yourBox.getValue().length());
sometimes you lose anyway the focus while rendering the complete component. If this happens you can try to put the setFocus in a scheduleDeferred-Command, it means, after the rendering process of the browser is done, the code in execute() will be executed. So you can be sure, that no other component will get also a focus, and your component lose it again.
final TextBox yourBox = new TextBox();
root.add(yourBox);
yourBox.setValue("AMSTERDAM");
Scheduler.get().scheduleDeferred(new ScheduledCommand()
{
@Override
public void execute()
{
yourBox.setFocus(true);
yourBox.setCursorPos(yourBox.getValue().length());
}
});

Thomas Meyer
- 53
- 7
-
im sorry..but my question was about ListGrid not about TextBox. ListGrid doesnt have the method setCursorPos(). – Reddy Dec 12 '13 at 06:57