Page tree
Skip to end of metadata
Go to start of metadata
getUndoContext()

Description

Function to check if the current script execution is part of an undo or redo operation.

Available in: Controller.

Return Values

The function returns

  • 1 if the changes come from an undo operation,
  • 2 if the changes come from a redo operation,
  • nil if the changes do not come from an undo or redo operation.

You can use the following enumerators to identify the Undo Context Types.

Indexundo context
1UndoContext.inUndo
2UndoContext.inRedo

Example

-- do nothing if the change callback is executed as part of an undo or redo operation
function onP1Changed()
  if getUndoContext() then
    return -- do nothing
  end
  -- the following code is only executed if it is not part of an undo or redo operation
  local oldName = this.name
  local newName = "Some Name "..p1
  startUndoBlock("Name of '"..oldName.."' set to '"..newName.."'")
    this:setName(newName)
  endUndoBlock()
end
 
defineParameter("p1", onP1Changed)

2 Comments

  1. Sabine Pfeifer: Ready for proof-read. Please have a look. Thanks!