Changing text in TextChange event

I was doing some app testing today and noticed that Edit/Undo was no longer working for a particular textarea. After some debugging I determined it was caused by changing the textarea text within the TextChange event. In this case I was capitalizing a particular character (‘e’ in this case) using a regex search and replace. I placed the capitalizing in the TextChange event versus using “>” in the format field because using the “>” option was really, really slow when pasting a large amount of text into the textarea (10-15 seconds for a million characters). I know that this is a large amount but the calculator app that I build works with million digit numbers.

I guess at this point I am going to avoid using this functionality at all. It is a shame that you can’t intercept a single character and replace it during the keydown event.

At any rate I don’t want to get another app store reject because undo is not working.

I wanted to post this in case someone else notices that undo quits working and wonders why.

I tried it with ReplaceAll, same result.

Undo works fine if no code is in the TextChanged event, but it only undoes the last few keystrokes when there is code in the TextChange event. It’s as if a timer fires and only the last action is undone then …

The issue seems to be linked to anything that changes the text outside of the keyboard. I tried changing the text in a timer or in a button ; whatever is typed after the text change by code is undoable, not what has been changed by entering through the keyboard.

For the issue of the million characters, maybe it is time to use a windowed data system, where not everything is in the control, but only a subset. And to put it back into the million long variable when the textarea is idle. That is the way most unlimited text word processors such as Word do it.

Well what I plan to do at this point is to handle the capitalization in a EditPaste menu handler which is working well (and fast) even with large paste sizes. Million character pastes are almost instantaneous. I am going to ignore changing characters typed for now.