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.

2 Comments

Andrew Thompson

Please help.

I've been struggling with implementing undo all night and have got nowhere.

Where do 'register callbacks' and 'define callbacks' go? I get a script compile error wherever I put it. What does 'glxapp_initializeApplication is an ideal place to do this' mean? It appears twice, once in the application stack and again in the framework stack - it throws an error when I put it in either.

I have a simple field called 'write' on a card and an edit menu.

Trevor DeVore

@Andrew - and are not commands which is why you get the compile error.

is a message sent to your application stack. You would never modify the framework stack. If you haven't read the PDF about messages then I would recommend doing that:

http://revolution.screenstepslive.com/s/revolution/m/glxapp/l/5546-properties-messages

The command you are interested in adding to the handler is < undoRegisterEditFieldType>.

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.