Posted: Fri Mar 16, 2012 7:04 am
Would it be ok if keywords will be hyperlinks? If yes, can this document contain other types of hyperlinks, such as URLs?
Support forums for TRichView, ScaleRichView, Report Workshop and RVMedia components
https://writeally.com/forums/
Code: Select all
function SelectFld(rve: TCustomRichViewEdit): Boolean;
var s: String;
ItemNo, Offs, Offs1, Offs2: Integer;
begin
Result := False;
if rve.SelectionExists then
exit;
rve := rve.TopLevelEditor;
ItemNo := rve.CurItemNo;
Offs := rve.OffsetInCurItem;
if (rve.GetItemStyle(ItemNo)<0) or
(Offs<=rve.GetOffsBeforeItem(ItemNo)) or (Offs>=rve.GetOffsAfterItem(ItemNo)) then
exit;
s := rve.GetItemText(ItemNo);
Offs1 := Offs;
while (Offs1>=1) and (s[Offs1]<>'[') do
dec(Offs1);
if Offs1<1 then
exit;
Offs2 := Offs;
while (Offs2<=Length(s)) and (s[Offs2]<>']') do
inc(Offs2);
if Offs2>Length(s) then
exit;
rve.SetSelectionBounds(ItemNo, Offs1, ItemNo, Offs2+1);
Result := True;
end;
procedure TForm3.RichViewEdit1RVMouseUp(Sender: TCustomRichView;
Button: TMouseButton; Shift: TShiftState; ItemNo, X, Y: Integer);
begin
if SelectFld(RichViewEdit1) then begin
Application.MessageBox(PChar('Here you can display a form to edit '+RichViewEdit1.GetSelText), 'Test', 0);
RichViewEdit1.InsertText('New value');
end;
end;