Getting length of TextBox value during key event?

60 views
Skip to first unread message

rl

unread,
Feb 10, 2012, 10:55:46 PM2/10/12
to google-we...@googlegroups.com
During a key event (down,press or up), is there a way to get the length of the TextBox as it is being modified?  The value isn't updated until the input is accepted so I can't just use getValue().length();  For example, if the value is "HELLO" (length of 5 characters) and the user presses the delete key 4 times, the value length is still 5 until the textbox blurs.   I want to get at the temporary value as it's being edited.

How do I do it?

linhua

unread,
Feb 15, 2012, 2:13:34 AM2/15/12
to Google Web Toolkit
From my point of view,

You can get which key(like del) has been pressed in the event, you
also can get event source(the text box). You can write a method to
calculate the length yourself.

Thomas Broyer

unread,
Feb 15, 2012, 4:41:09 AM2/15/12
to google-we...@googlegroups.com
The value should have been updated in KeyUp (it obviously won't be in KeyDown and KeyPress as, as you said, they're cancelable events)
Reply all
Reply to author
Forward
0 new messages