How can i remember current caret postion and then after doing some processing, and move the caret back to the original position:
example:
1. remember current caret position
2. process the rv items from 0 to count
3. during processing if located a identified item tag, select and delete it.
4. after that call to move the caret back to the original location
Move caret to original position
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
You cannot store position as a number of characters from the beginning, because this value becomes incorrect if you delete something before this position.
I think the simplest way is to store the following value:
1) RVData := RichViewEdit1.TopLevelEditor.RVData.GetSourceRVData;
2) ItemNo := RichViewEdit1.TopLevelEditor.CurItemNo;
3) Offs := RichViewEdit1.TopLevelEditor.OffsetInCurItem;
When deleting item from RVData.GetRVData, with indices <= ItemNo, the stored value of ItemNo must be decremented.
When deleting characters from the ItemNo-th item of RVData.GetRVData, Offs must be adjusted.
The caret is restored in this way:
RVData := TCustomRVFormattedData(RVData.Edit);
RVData.SetSelectionBounds(ItemNo, Offs, ItemNo, Offs);
I think the simplest way is to store the following value:
1) RVData := RichViewEdit1.TopLevelEditor.RVData.GetSourceRVData;
2) ItemNo := RichViewEdit1.TopLevelEditor.CurItemNo;
3) Offs := RichViewEdit1.TopLevelEditor.OffsetInCurItem;
When deleting item from RVData.GetRVData, with indices <= ItemNo, the stored value of ItemNo must be decremented.
When deleting characters from the ItemNo-th item of RVData.GetRVData, Offs must be adjusted.
The caret is restored in this way:
RVData := TCustomRVFormattedData(RVData.Edit);
RVData.SetSelectionBounds(ItemNo, Offs, ItemNo, Offs);