我SuggestBox
接受用户输入并使用GWT在弹出窗口中显示suggestions
。
SuggestBox suggestBox = new SuggestBox(myData, new TextArea());
如何阻止用户在没有建议的TextArea
中添加字符?
我认为SuggestBox
会检查已放入TextArea
的文字,然后显示建议。但是我怎么能防止那些不再匹配的角色呢?
答案 0 :(得分:1)
如果你真的需要那个
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);