0

我已经使用 GWTSuggestBox获取用户输入并suggestions在弹出窗口中显示。

SuggestBox suggestBox = new SuggestBox(myData, new TextArea());

如何防止用户将TextArea不存在建议的字符放入其中?

我认为SuggestBox检查已放入的文本,TextArea然后显示建议。但是我怎么能防止不再匹配的字符呢?

4

1 回答 1

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);
于 2013-03-09T09:16:45.540 回答