On 15 sep, 18:05, jucimarjr <junior.juci...@gmail.com> wrote:
> Does anyone know if is possible, when I have a suggestBox and clicking
> at the button TAB the suggestion don't be selected? I mean, if I click
> at the TAB button, the word that I put in the box keep there.

First, you'd have to disable the "auto-select" behavior which is "on"
by default
http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/gwt/user/client/ui/SuggestBox.html#setAutoSelectEnabled(boolean)

Then, add a ChangeHandler to the text box (getTextBox
().addChangeHandler()) where you'll ask the SuggestOracle whether the
text in the box is a valid suggestion (taken in the list) and if not
clear the text box (or reset to the previous value that you'd have
cached in "on focus", for example):
public void onChange(ChangeEvent event) {
   suggestBox.getSuggestOracle().requestSuggestions(
      new SuggestOracle.Request(suggestBox.getValue(), 1),
      new SuggestOracle.Callback() {
         public void onSuggestionsReady(SuggestOracle.Request request,
SuggestOracle.Response response) {
            if (response.getSuggestions() == null ||
response.getSuggestions().size() == 0) {
               suggestBox.setValue("", false);
            }
         }
      }
   );
}

or did I misunderstand your need?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to