By default, the {@link SuggestBox} uses a {@link MultiWordSuggestOracle} asits oracle. Below we show how a {@link MultiWordSuggestOracle} can beconfigured:
MultiWordSuggestOracle oracle = new MultiWordSuggestOracle(); oracle.add("Cat"); oracle.add("Dog"); oracle.add("Horse"); oracle.add("Canary"); SuggestBox box = new SuggestBox(oracle);Using the example above, if the user types "C" into the text widget, the oracle will configure the suggestions with the "Cat" and "Canary" suggestions. Specifically, whenever the user types a key into the text widget, the value is submitted to the
MultiWordSuggestOracle
. Note that there is no method to retrieve the "currently selected suggestion" in a SuggestBox, because there are points in time where the currently selected suggestion is not defined. For example, if the user types in some text that does not match any of the SuggestBox's suggestions, then the SuggestBox will not have a currently selected suggestion. It is more useful to know when a suggestion has been chosen from the SuggestBox's list of suggestions. A SuggestBox fires {@link SuggestionEvent SuggestionEvents}whenever a suggestion is chosen, and handlers for these events can be added using the {@link #addEventHandler(SuggestionHandler)} method.
|
|