robot_2Generated
code_blocksInput

Description

The OnUndo field is an event handler that is triggered whenever an undo operation is executed within the UndoSystem. This field is of type System.Action<Sandbox.Helpers.UndoSystem.Entry>, allowing you to specify a method that takes an Entry object as a parameter. This can be used to perform additional actions or logging when an undo operation occurs.

Usage

To use the OnUndo field, you can assign a method to it that matches the signature of System.Action<Sandbox.Helpers.UndoSystem.Entry>. This method will be called automatically whenever an undo operation is performed.

Example

// Example of subscribing to the OnUndo event
UndoSystem undoSystem = new UndoSystem();

// Define a method that matches the Action<Entry> signature
void OnUndoAction(Sandbox.Helpers.UndoSystem.Entry entry)
{
    // Perform custom logic when an undo is executed
    // For example, logging the undo action
    Log.Info($"Undo performed: {entry.Title}");
}

// Subscribe the method to the OnUndo event
undoSystem.OnUndo += OnUndoAction;

// Now, whenever an undo is executed, OnUndoAction will be called.