Based on this topic, I implemented a custom Undo class, and it works fine:
Code: Select all
class procedure TRVUndoModifyMathObject.AddUndo(RVData: TRichViewRVData;
ItemInfo: TRVMathObjectItemInfo);
var
Edit: TCustomRichViewEdit;
UndoList: TRVUndoList;
UndoItem: TRVUndoModifyMathObject;
begin
if RVData = nil then Exit;
Edit := TCustomRichViewEdit(RVData.GetAbsoluteRootData.GetParentControl);
UndoList := TRVEditRVData(RVData).GetUndoList;
if Assigned(UndoList) then
begin
UndoItem := TRVUndoModifyMathObject.Create;
UndoItem.Action := rvuMisc;
UndoItem.FInputExpression := ItemInfo.Expression;
UndoItem.FOutputExpression := ItemInfo.OutputExpression;
UndoItem.FOutputFormat := ItemInfo.OutputFormat;
UndoItem.FTitle := ItemInfo.TextAlias;
UndoItem.FItemNo := RVData.GetItemNo(ItemInfo);
UndoList.AddInfo(UndoItem, Edit);
end;
end;
Code: Select all
...
if AEdit.CanChange then
begin
AEdit.BeginUndoCustomGroup('Modify Math Object');
TRVUndoModifyMathObject.AddUndo(AEdit.RVData, ItemInfo);
ItemInfo.Expression := MemoInput.Lines.Text;
ItemInfo.OutputExpression := EditOutput.Text;
ItemInfo.OutputFormat := ComboBoxOutputFormat.Text;
ItemInfo.TextAlias := EditTitle.Text;
AEdit.Change;
AEdit.RefreshAll;
end;
...