Hi,
What is the correct way to replace text in AdvRichEditor with appropriate Hyperlink?
For example I have a text:
Please click to [LINK] to continue
I would like to replace [LINK] with TMS WEB Core Framework for creating modern web applications in Delphi.
I tried with replacefirst and SetSelectionHyperlink afterwards but it doesn't select correctly.
Kind regards,
Bostjan
You need to select (or programmatically select) the word link, replace it with the text you need and when this replaced text is selected, you can call:
begin
advricheditor1.SetSelectionHyperlink('yourlinkURL');
end;
Hi, Bruno!
My problem is how to select the replaced text? What is the correct way to find position of that replaced text?
Kind regards,
Bostjan
Text selection is based on character position (similar to what is available in a standard VCL TRichEdit)
You can use:
AdvRichEditor.SelectText(FromChar, ALength: integer);
or you can use properties
AdvRichEditor.SelStart / AdvRichEditor.SelLength
Hi, Bruno!
How do I find position of text? The only way I found it is to save string with AdvRichEditor.ContentAsPlainText then search in string for the text position. Is that the correct way or it exists some better solution?
KInd regards,
Bostjan
Yes, the calculation would be based on the plain text and find the text position this way if you need to do it fully programmatically.
Thank you, I will use that solution then.