I have a series of objects that contain a text value that is updated based on the text the user enters in a custom TextArea component. One of the objects that is updated is bound to another label.The label shoud get updated as and when the user types in.
So, I used KeyboardEvent.KEY_DOWN event. And in the event handler, I set the text of the first object in the series of objects. The first object's setter calls the setter of the second object, and so on. Now, the label gets updated. But sometimes, the last change to the textarea doesn't get reflected. When I type another character or delete a character, the previous change gets reflected in the label. That is, the label is, most of the times, a step behind the text area. I figured out that the object's text that was bound to the label was also one step behind. I couldn't find a solution or the problem.
When I use Event.CHANGE, this problem doesn't occur and the label gets updated properly. But I am curious why KeyBoardEvent.KEY_DOWN event didn't work. If any of you know, please let me know!
Thanks for your inputs.
Depending on which TextArea and your customization, KEY_DOWN may get
aggregated and applied later. CHANGE event is when the text changed.