Wow, that took me way too many hours to find a 'decent' solution/
workaround.
I needed to, effectively, submit a form/complete a task if the user
hit ENTER when the suggestion list was hidden or otherwise let the
suggestion fill in the box and set focus back in that box (imagine
multi-keyword suggestions).
Though when I added a KeyDownHandler (as is used within the SuggestBox
source code itself) the suggestDisplay.isSuggestionListShowing()
always returned false even when it had just previously done so.
Well, the trick is to add your handler before the suggest box adds its
handler:
SuggestBox.DefaultSuggestionDisplay suggestDisplay = new
SuggestBox.DefaultSuggestionDisplay();
TextBox textBox = new TextBox();
textBox.addKeyDownHandler(this);
suggestBox = new SuggestBox(new MySuperAwesomeSuggestOracle(),
textBox, suggestDisplay);
Now inside of my keyDownHandler the isSuggestionListShowing() returns
true!
I sincerely hope I save someone else an afternoon. (Note that this
method also gets rid of that annoying bug of receiving two keyDown
events per event when attaching a handler to the suggestBox)
On Mar 8, 3:18 pm, Nate Bauernfeind <[email protected]>
wrote:
> Did you ever solve this problem?
>
> On Feb 10, 6:11 am, Torgeir <[email protected]> wrote:
>
>
>
>
>
>
>
> > Am looking for an easy way to avoid a keypress from the textbox of a
> > suggestbox when the user selects an item from the suggested dropdown.
>
> > I need to handle both in my application, but if the user selects an item
> > from the suggested drop down, i want to avoid the event from the keydown
> > handler on the wrapped textbox.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.