How Can I Implement Undo For Changes Made To a Field?
The framework provides helpers that will implement undo for changes made while editing text in a field. When focus leaves the field the user will be able to revert to original contents of the field. This article explains how it works.
Turn On Automatic Undo Queue for Field Edits
To have the framework automatically provide undo while a user is typing in a field you call the undoRegisterEditFieldType command. An appropriate place to make the call would be in glxapp_initializeApplication.
undoRegisterEditFieldType will insert a front script that will monitor text input. The button that is inserted as a front script is named glxEditFieldUndoTypeFrontScript. The script does all of the work of maintaining an undo queue for you while the user is entering text in a field.
If you want to turn undo monitoring off for a specific field just set the uEnableFieldUndo of the field to false.
The only thing you have to do is keep the Edit > Undo/Redo menu options in sync.
Keeping Edit Menu in Sync
When the framework is monitoring field edits undoCanUndo() will automatically detect if focus is in a field and determine if an undo action is in the queue.