views:

151

answers:

1

I want to detect when the contents of my GWT RichTextArea become 'dirty' (have been changed by the user) in order to enable a 'save' button accordingly.

I suppose I could listen for key presses that are likely to have changed the contents; but browser support for key presses is notoriously quirky.

I suppose I could, before editing begins, save the original contents in a variable, and upon key press, compare the current contents against that variable, but doing that on each key press is going to be really slow.

Is there some neat way to achieve RichTextArea dirty-detection?

A: 

You could always compare the original text to the current text on a timer (every second or two). Start the timer in onFocus(), and stop it onBlur()

Steve Armstrong