Posted: Sat Nov 26, 2011 6:59 pm
Yes, as I said in the previous post, the modified code inserts not all links, so they are mismatched.
The solution: when adding links to the list (in RichView1), do not add the link targets as tags. Use the link index instead.
The code below is for the latest version of TRichView, where tags are strings.
For older versions, remove StrToInt and IntToStr, and exclude rvoTagsArePChars from RichView1.Options.
Now, we need to modify RichView1.OnJump and OnItemHint:
The solution: when adding links to the list (in RichView1), do not add the link targets as tags. Use the link index instead.
The code below is for the latest version of TRichView, where tags are strings.
For older versions, remove StrToInt and IntToStr, and exclude rvoTagsArePChars from RichView1.Options.
Code: Select all
procedure TFmain.EnumLinksProc(RVData: TCustomRVData; ItemNo: Integer;
var UserData1: Integer; const UserData2: String;
var ContinueEnum: Boolean);
var StyleNo: Integer;
begin
StyleNo := RVData.GetItemStyle(ItemNo);
if RVData.GetRVStyle.TextStyles[StyleNo].Jump and
(RVData.GetRVStyle.TextStyles[StyleNo].Color = clGreen) then
RichView1.AddNLTag(RVData.GetItemText(ItemNo), RVData.GetItemStyle(ItemNo),
0, IntToStr(UserData1));
if RVData.GetItem(ItemNo).GetBoolValueEx(rvbpJump, RVData.GetRVStyle) then
inc(UserData1);
ContinueEnum := True;
end;
Code: Select all
procedure TFmain.RichView1Jump(Sender: TObject; id: Integer);
var RVData: TCustomRVFormattedData;
ItemNo: Integer;
begin
RichView1.GetJumpPointLocation(id, RVData, ItemNo);
id := StrToInt(RVData.GetItemTag(ItemNo));
// here, id = link index in RichViewEdit
RichViewEdit1.GetJumpPointLocation(id, RVData, ItemNo);
RVData := TCustomRVFormattedData(RVData.Edit);
RVData.SetSelectionBounds(ItemNo, RVData.GetOffsBeforeItem(ItemNo),
ItemNo, RVData.GetOffsAfterItem(ItemNo));
RichViewEdit1.SetFocus;
end;
Code: Select all
procedure TFmain.RichView1ItemHint(Sender: TCustomRichView;
RVData: TCustomRVData; ItemNo: Integer; var HintText: String);
var id, LItemNo: Integer;
LRVData: TCustomRVFormattedData;
begin
if RVData.GetItem(ItemNo).GetBoolValueEx(rvbpJump, RVData.GetRVStyle) then begin
id := StrToInt(RVData.GetItemTag(ItemNo));
// here, id = link index in RichViewEdit
RichViewEdit1.GetJumpPointLocation(id, LRVData, LItemNo);
HintText := LRVData.GetItemTag(LItemNo);
end;
end;