Page 1 of 1

Undo problems

Posted: Wed Feb 22, 2006 9:45 pm
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

Posted: Sun Feb 26, 2006 11:02 am
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)