Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Hull and Outfitting

Undo/Redo Support for Callbacks

  • Last UpdatedJan 09, 2024
  • 2 minute read

Marine Undo/Redo is supported by certain callback actions for FORM, MENU and GADGET objects. Appware can decide, for any callback action, whether it is 'undoable', that is, supports the Undo/Redo buttons on the main toolbar. If so then a Marine UNDOABLE object must be created and populated with the required Undo and Redo action strings, and then assigned to the appropriate F&M object callback.

For example:

In the form definition extract below:

Setup form !!myform . . .

Title |MyForm with undoable callbacks|

-- create form members as UNDOABLE objects for each F&M callback action,

-- which is to be undoable, for example, form OK callback, gadget callbacks

member !okUndo is UNDOABLE

member !doitUndo is UNDOABLE

. . .

button .doit |Do it| …

. . .

button .ok | OK | … OK

exit

define method .myform()

-- Constructor

. . .

-- Set up callbacks and assign any undo/redo actions to their undoable objects

!this.okCall = !this.formOK()

!this.okUndo.description( 'MyForm OKcall undo/redo actions' )

!this.okUndo.undoAction( ' ' )

!this.okUndo.redoAction( ' ' )

-- assign undoable to form OK callback

!this.setUndoable( 'OKcall', !okUndo )

--

!this.doit.callback = '!this.gadgetActions('

!this.doitUndo.description( 'MyForm doit button undo/redo actions' )

!this.doitUndo.undoAction( '!this.undoitAction( )' )

!this.doitUndo.redoAction( 'this.doitAction( )' )

-- assign undoable to do-it button callback

!this.doit.setUndoable( !this.doitUndo )

. . .

endmethod

define method .formOK()

-- OKcall callback

. . .

endmethod

define method .doitAction()

-- doit button callback

-- actions for doit/re-doit

. . .

endmethod

define method .undoitAction( )

-- undo method for doit button

-- actions to undo the doit/re-doit action

. . .

endmethod

Notes

  1. In most cases the Undoable object's undoAction and redoAction are not required! This is because undo/redo is essentially linked to the state of the Marine database rather than to the state of a form or its gadgets. Once a form is dismissed from the screen its state is not usually maintained, but is regenerated by the INIT callback next time it is displayed. Most forms which are sensitive to database changes, and remain displayed, are updated via their AUTOCALL callback (Tracker system), which again removes the need for explicit undo/redo support.

  2. The Undoable object must be a form member (preferred) or a global variable or it cannot be held by F&M.

When a callback is executed, if an UNDOABLE object is present, then F&M modifies the undo/redo stack by means of the following actions:

undoable.Add( )

execute gadget callback

undoable.endUndoable( )

Methods to assign a Marine UNDOABLE object to a callback, and to query a callback's UNDOABLE object are supported.

Not all callbacks are candidates for undo/redo. The following sections detail what is possible.

TitleResults for “How to create a CRG?”Also Available in