I have a TextBox
on a Panel
and I want to be notified when the value of the 'TextBox' changes.
I have tried the following event handlers:
ChangeHandler
ValueChangeHandler
KeyPresshandler
My problem is that the ValueChangeHandler
and ChangeHandler
only fire when the focus leaves the controls. The KeyPressHandler
fires correctly, but before the TextBox
itself has seen the event, which means that a call to getText()
from my event handler sees a stale value.
Is there an event that would work exactly like KeyPressHandler
but be fired after the TextBox
has seen the event?
EDIT: this behaviour is seen in Chrome and IE8 on Windows XP
Try the KeyUpHandler.
A very robust (though not very elegant) solution which catches ALL changes including copy/pasty via mouse or text suggestions inserted via a virtual keyboard (e. g. such as the ios 8 keyboard) is to start a timer on focus and to check the value of the textbox in an appropriate time interval. The timer is stopped on blur (don't forget to do a final check on blur).
I am not aware of any "handler-based" solution to catch all textbox changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With