我让SuggestBox
接受用户输入并使用GWT在弹出窗口中显示suggestions
。
SuggestBox suggestBox = new SuggestBox(myData, new TextArea());
如何防止用户在没有建议的
TextArea
中放置字符?我认为
SuggestBox
检查已放入TextArea
的文本,然后显示建议。但是,如何防止不再匹配的字符呢? 最佳答案
如果您真的需要
TextArea area = new TextArea();
area.addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
if(event.getNativeKeyCode()==13 ||....){//Add remaining key codes which you dont want.For example i added enter key which keycode is 13.Remove that and add your key codes there.
event.preventDefault();
}
}
});
然后
SuggestBox suggestBox = new SuggestBox(myData,area);