我正在使用gwt中的建议框,并将SelectionHandler和onFocusHandler添加到建议框中,但在选择之后,建议列表仍然可见..不应该是这种情况。
在选择其中一个建议后,我该怎么做才能隐藏建议清单。?
suggestBox.getValueBox().addFocusHandler(new FocusHandler() {
@Override
public void onFocus(FocusEvent event) {
if(suggestBox.getText().equals("")){
suggestBox.setText(" ");
suggestBox.showSuggestionList();
suggestBox.setText("");
}
}
});
suggestBox.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {
@Override
public void onSelection(SelectionEvent<Suggestion> arg0) {
if (arg0.getSelectedItem() instanceof Suggestion) {
//code to take actions after selection
}
}
});
答案 0 :(得分:2)
选择其中一项后,我该怎么做才能隐藏建议清单 建议。?
为什么不在选择处理程序中隐藏列表?
@Override
public void onSelection(SelectionEvent<Suggestion> arg0) {
if (arg0.getSelectedItem() instanceof Suggestion) {
//code to take actions after selection
}
DefaultSuggestionDisplay display = (DefaultSuggestionDisplay) suggestBox.getSuggestionDisplay();
display.hideSuggestions();
}