Page 1 of 1

Stuck into HyperLink style when there is only a link inside

Posted: Thu Oct 09, 2014 11:19 am
by gdemers_logilys
I made a TFrame in Delphi with a TRichViewEdit in it with buttons for alignement, color, font, font-size, etc...

If I paste a link inside an empty TRichViewEdit, I'm stuck inside the hyperlink. Whatever I try to type inside the edit goes in the Link label.

Is there something I can do right after a link is pasted to "finish" the link label so the next thing I type in is not in the link ?

The OnPaste event seems to be called before the paste is done and I don't know when it's an hyperlink.


Thanks

Posted: Thu Oct 09, 2014 2:01 pm
by Sergey Tkachenko
The recommended solution is closing the link when the user types some characters that should not belong to the link, such as space characters.

If you use RichViewActions, you can use TrvActionInsertHyperlink.TerminateHyperlink. Search in the main form of the ActionTest demos for "rvActionInsertHyperlink1.TerminateHyperlink".

If you do not use RichViewActions, you can take as a sample the demo in Demos\DelphiUnicode\Assorted\Hypertext\CreateHyperlink. See TForm1.TerminateHyperlink.

There is also a demo Demos\DelphiUnicode\Assorted\Hypertext\URLs\.
It contains a ready-to-use URLScan.pas unit. It also provides TerminateHyperlink procedure. But this procedure works in conjunctions with the event OnItemTextEdit (see TForm1.rveItemTextEdit in this demo).