How to use Redo after TRVUndoList.AddInfo?
Posted: Wed Jun 12, 2024 5:34 pm
Hi, I have read other forum threads regarding "Custom Undo" operations, but I did not find an answer.
Based on this topic, I implemented a custom Undo class, and it works fine:
The main code that applies the changes:
Unfortunately, Redo does not respond... What should I change/add to make the Redo stack work properly?
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;
...