TrvActionInsertHyperlink.TerminateHyperlink

<< Click to display table of contents >>

TrvActionInsertHyperlink.TerminateHyperlink

Helps to terminate hyperlinks when typing in rve.

procedure TerminateHyperlink(rve: TCustomRichViewEdit);

If the selection is empty, the current text item is a hyperlink, and the caret is at the end of this item, this function assigns the index non-hypertext style to the current text style (rve.CurTextStyleNo). GetNormalStyleNo is used.

Example [VCL]:

procedure TForm1.RichViewEdit1KeyPress(Sender: TObject; var Key: Char);

begin

  if Key in [#9' '','';'then begin

    rvActionInsertHyperlink1.DetectURL(RichViewEdit1);

    rvActionInsertHyperlink1.TerminateHyperlink(RichViewEdit1);

  end;

end;

When the user types something at the end of a hyperlink, new characters are added to the hyperlink's text. But when he/she types a space character (or tab, or comma, or Enter, or semicolon), the current text style becomes a non-hypertext, so this and subsequent characters will not be added to the hyperlink's text.

You should call this method:

in OnKeyPress event (in OnUTF8KeyPress for Lazarus) when the user types tab, space, comma or semicolon characters

in OnKeyDown event when the user pressed ENTER.