I have SuggestBox
taking user input and displaying suggestions
in a popup using GWT.
SuggestBox suggestBox = new SuggestBox(myData, new TextArea());
How can I prevent the user to put characters in the TextArea
for which no suggestions exist?
I think the SuggestBox
examines the text that has been put into the TextArea
, and then displays the suggestions. But how could I prevent characters that do no match anymore?
If you really need that
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();
}
}
});
And then
SuggestBox suggestBox = new SuggestBox(myData,area);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.