Art*_*uro 3 gwt textarea selectall
我的GWT页面有一个TextArea,我希望它具有焦点,并在加载此页面时选择所有文本.我尝试下面的代码,但它根本不起作用.你能帮助我吗?谢谢
final TextArea myText = new TextArea();
myText.setCharacterWidth(50);
myText.setVisibleLines(20);
myText.setText("Just try something");
RootPanel.get("textContainer").add(myText);
myText.setVisible(true);
myText.setFocus(true);
myText.selectAll();
Run Code Online (Sandbox Code Playgroud)
文件TextBox.selectAll()说:
This will only work when the widget is attached to the document and not hidden.
Run Code Online (Sandbox Code Playgroud)
很可能TextBox你打电话时还没有附加到DOM .selectAll().
尝试使用Scheduler:
final TextArea myText = new TextArea();
myText.setCharacterWidth(50);
myText.setVisibleLines(20);
myText.setText("Just try something");
RootPanel.get("textContainer").add(myText);
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
// your commands here
myText.setVisible(true);
myText.setFocus(true);
myText.selectAll();
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1448 次 |
| 最近记录: |