Detect a "change" inside a textarea?

BlitzMax Forums/MaxGUI Module/Detect a "change" inside a textarea?

Grisu(Posted 2008) [#1]
Hi everyone!

I'm looking for the smartest way to detect if the contents of a textarea has been changed by the user.

I need this to indicate that the data needs to be saved (via an "*" in filename). This functionality is implemented in the BMX IDE.
Though I couldn't understand the source code... :/



Thanks!

Grisu


tonyg(Posted 2008) [#2]
This is how I would do it (and how it seems the IDE does it)
1) CreateTextArea and set filesrc and src to the returned gadget.
2) Detect if anything is typed in the textarea
When it is
a) Add the change to the undo list.
b) if src is 'clean' create a new textarea and set src to 'dirty'
c) If src=dirty set the 'Save required' flag.
4) If Undo is pressed remove the latest change from the undo and update the src textarea.
5) When UNDO is empty set src back to the gadget held in filesrc and turn off the 'save required' changed and set src to clean
6) If, at any point, file is saved then set filesrc=src and src=clean.
... I think.


jsp(Posted 2008) [#3]
If you don't go the long way with undo and redo you could store the 'original' content and sit and wait for the GADGET_ACTION event (A GADGET_ACTION event occurs whenever the user modified a TextArea's text. ). If the event occurred you can act directly on that one or may set a flag to remember that the text could be different than the original, which can be checked with your original one.


Grisu(Posted 2008) [#4]
Thanks a lot for the explanations!

Issue solved! :)