Undo problems

General TRichView support forum. Please post your questions here
Post Reply
aoven
Posts: 45
Joined: Wed Nov 09, 2005 7:28 pm

Undo problems

Post by aoven »

I'd like to do something like this in code:

Code: Select all

procedure SetItemText(aRV: TCustomRVData; aItemNo: Integer; const aText: WideString);
begin
  if aRV.GetItemTextW(aItemNo) <> aText then begin
    aRV.SetItemTextW(aItemNo, aText);
    aRV.GetItem(aItemNo).StyleNo := RVSTYLE_MODIFIED;
  end;
end;
I can pass both RVE.RVData and RV.RVData to this method. The problem is, these actions don't show in the undo list for RVE. Do I need to delete the item and reinsert it with new text & style to make undo list pick it up?
If so, is there some way to use the same code for both TRichViewEdit and TRichView? I use both components in my application and I'd like to be able to pass their RVData to the same SetItemText method.

Aleksander
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, direct assignment to StyleNo cannot be undone.
Currently, the only way to change item style as an editing operation is selecting it and applying text style:

First, initiate editing of this RVData (it is important if your document has tables):

Code: Select all

aRV := aRV.Edit;
Now aRV is a RVData of top level editor:

Code: Select all

var rve: TCustomRichViewEdit;

rve := RichViewEdit1.TopLevelEditor;
rve.SetItemTextEdW(aItemNo, aText);
rve.SetSelectionBounds(aItemNo, rve.GetOffsBeforeItem(aItemNo),
  aItemNo, rve.GetOffsAfterItem(aItemNo));
rve.ApplyTextStyle(RVSTYLE_MODIFIED)
Post Reply