SuggestBox GWT showing all options on Enter key -


I need to create a SuggestBox that will show all the options by pressing the Enter key. I have written the following implementation, and it is working fine. I would like someone to review my implementation and tell me if it will create problems in a particular scenario. Apart from this, SuggestOracle given to the SuggestBox should have a default suggestion set, method set default suggestions () by calling on MultiWordSuggestOracle. Any user of my suggestion should be transparent for this fact. So I think that I have to wrap (or expand) a multi-directional correct oak to do the default suggestion setting Can you please suggest that what would be a good way to do this?

  PublicSuggestBoxWithAllOptions Suggest Box Provides KeyPressHandler {Public SuggestBoxWithAllOptions (MultiWordSuggestOracle oracle) {Super (Oracle); This.addKeyPressHandler (this); } Public override @ keypress (key press event event) {char c = event.getCharCode (); Int i = this.getText (). Length (); If (C == Keyboard Listener. KEY_ENTER & amp; i == 0) {/ * Since the query string is empty, the default suggestions will be listed * / this.showSuggestionList (); }}} / * Code * / list to start SuggestBox & lt; String & gt; Suggestion = New Arrestist & lt; String & gt; (); Suggestions.add ("tablet"); Suggestions.add ("capsule"); MultiverseSearchOrakal myOracle = New Multi-Word Notification (); MyOracle.addAll (suggestions); MyOracle.setDefaultSuggestionsFromText (suggestions); Suggestbox mySuggest = New SuggestBoxWithAllOptions (myOracle);  

This is another way to show all the suggestions that looks great for me Adding a button for the button can be styled to look like a drop down box arrow.

  Public category DropDownSuggestbox Composite {Expands Public Dropdown Suggestions Box) {FlopNail Layout = New FlopNail (); Last button drop down button = new button (); DropDownButton.setStyleName ("Slate DropdownIcon"); DropDownButton.setText ("Show Options"); DropDownButton.addClickHandler (new clickhandler) {@Override Public Zero Click Click (click Event Event) {suggestBox.setFocus (true); SuggestBox.showSuggestionList ();}}); Layout.add (suggestBox); Layout.add (dropDownButton); InitWidget (layout); SetStylePrimaryName ("Slate DropDownSuggestBox"); }}  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -