Gwt 光标位置到listgird文本框中字符串的末尾?
是否有任何方法可以将光标位置设置为listgird文本框中字符串的结尾。 例子: 输入网站名称,一旦用户单击listgird的单元格,它将显示“http://”,现在我希望光标位置位于字符串的末尾。> 这很容易:Gwt 光标位置到listgird文本框中字符串的末尾?,gwt,smartgwt,Gwt,Smartgwt,是否有任何方法可以将光标位置设置为listgird文本框中字符串的结尾。 例子: 输入网站名称,一旦用户单击listgird的单元格,它将显示“http://”,现在我希望光标位置位于字符串的末尾。> 这很容易: TextBox yourBox = new TextBox(); root.add(yourBox); yourBox.setValue("AMSTERDAM"); yourBox.setFocus(true); yourBox.setCurso
TextBox yourBox = new TextBox();
root.add(yourBox);
yourBox.setValue("AMSTERDAM");
yourBox.setFocus(true);
yourBox.setCursorPos(yourBox.getValue().length());
有时渲染整个组件时会丢失焦点。如果发生这种情况,您可以尝试将setFocus放在schedulederferred命令中,这意味着在浏览器的呈现过程完成后,将执行execute()中的代码。因此,您可以确定,没有其他组件也会获得焦点,并且您的组件会再次失去焦点
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());
}
});
你看过这个吗@Reddy这个问题与GWT或SmartGWT有关?@RAS与SmartGWT@Reddy我不认为有任何这样的内置功能。我很抱歉,我的问题是关于ListGrid的,不是关于TextBox的。ListGrid没有setCursorPos()方法。