That's correct, onChange fires after the text box looses focus, but  
you can listen to onkeypress. onKeypress is fired before the text box  
is updated allowing you to cancel the keypress if desired. The trick  
is to use DeferredCommand.addCommand() to handle the text.

public void onKeyPress(Widget sender, char keyCode, int modifiers){
   // check if the keycode is something you are concerned about
   DeferredCommand.addCommand(new Command(){
     public void execute(){
       // read the updated text in the textbox now.
     }
   });
}

-jason

On Dec 10, 2008, at 5:50 PM, dhoffer wrote:

>
> Does anyone know how to configure GWT's TextBox so I can be notified
> when its contents changes?
>
> I have just found out that addChangeListener does not work because it
> only gets fired when the user leaves the text box.
>
> Also addKeyboardListener does not do what I need because this is fired
> BEFORE the contents of the text box have been changed/updated (so
> calling getText() returns the previous text).
> >


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to