User:Tempel:UndoEditField
From REALbasicWiki
| |||||
|---|---|---|---|---|---|
| Available for | | ||||
| Thomas Tempelmann's UndoEditField is a a lean EditField subclass with proper Undo behaviour | |||||
| License | Free for unlimited use | ||||
| Download | http://www.tempel.org/rb/#undoeditfield | ||||
| Developer's site | http://www.tempel.org/rb/#undoeditfield | ||||
There are quite a few attempts at a "proper" EditField with Undo support (e.g. UndoFlattenEdit and Undo Toolkit)
They all attempt to deal with the various ways of how text can be altered in an EditField, trying to track deletions etc. by intercepting lots of Events. I am not happy with that, as it's never guaranteed that everything's covered.
So I came up with a much simpler solution, which is based on the original rule of how Undo has to behave in a text editor:
As long as one types continuously, let's call it a text block, it's all assumed to be one typing action. And if one wants to undo typing, this entire block is undone in one go. This block typing is only broken up by actions such as moving the text cursor (by mouse or arrow keys - doesn't matter), moving to another UI control (i.e. losing focus on the text field), pasting data and other actions that break the flow of typing.
