Hi, Naive, little 'ol me is back. This time with TextBox and event questions.
I have a textbox and a button. When the page first loads the textbox is empty and the button is disabled. If one or more non-white-space characters are typed in the box then then I want the button to become enabled. I am sort-of doing this now -- except that it takes two characters to trigger the events. searchTerm.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { if (searchTerm.getValue().trim().equals("")) { searchButton.setEnabled(false); } else { searchButton.setEnabled(true); } } }); searchTerm.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (searchTerm.getValue().trim().equals("")) { searchButton.setEnabled(false); } else { searchButton.setEnabled(true); if (event.getCharCode() == KeyCodes.KEY_ENTER) { getInfo(); } } } }); I started with only the ChangeHandler but I do not seem to understand what defines "chenge". I know that my audience will want to use "enter" as a "submit" so I added the KeyPressHandler. So with the above I see the following: With a blank TextBox I have a disabled searchButton. If I type one non-whitespace character in the textbox nothing happens -- the searchButton does not become enabled. If I type a second non-whitespace character then the button does become enabled. Maybe I should use a KeyDown handler instead of a ChangeHandler? -- 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-tool...@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=.