RhinoDoc.Undo() makes RhinoDoc.UndoActive stay true forever

Hi @stevebaer and @dale.

When I use the RhinoDoc.Undo() method to undo the previous action it seems that it will not change the RhinoDoc.UndoActive property back to false after the action is done. Is this a bug or am I maybe missing something?

-Matti

Hi @mattipi,

Can you provided a simple example, that we can run here, that reproduces what you are seeing?

Thanks,

– Dale

Sorry to necro this, but seemed better than creating a new thread with the same question. Here’s a simple example that I just ran into.

Context: when this control has focus, I want to be able to trigger Rhino’s Undo/Redo.

If I just call RunScript("_Undo") everything works as expected, but if I want to use the Doc to do this, I have to add the EndUndoRecord which seems .. wrong?

private void TreeOnKeyDown(object sender, KeyEventArgs e)
{
    switch (e.KeyData)
    {
        case Keys.Control | Keys.Z:
        {
            e.Handled = e.SuppressKeyPress = true;
            // At this point, we have:
            // RhinoDoc.ActiveDoc.UndoRecordingIsActive = false
            // RhinoDoc.ActiveDoc.CurrentUndoRecordSerialNumber = 0
            if (!RhinoDoc.ActiveDoc.Undo())
                RhinoApp.WriteLine("Nothing to undo.");

            // Now we have:
            // RhinoDoc.ActiveDoc.UndoRecordingIsActive = true
            // RhinoDoc.ActiveDoc.CurrentUndoRecordSerialNumber > 0
            // So I need to add:
            if (RhinoDoc.ActiveDoc.UndoRecordingIsActive)
                RhinoDoc.ActiveDoc.EndUndoRecord(RhinoDoc.ActiveDoc.CurrentUndoRecordSerialNumber);
                    return;
        }
        case <...>
}