Still evaluating...
I have a case where a user clicks on a hyperlink which causes me to prompt a user on what they want to do. In one case I just replace the current item text with the user's text selection. In another case, I need to completely replace the hyperlink with user selected RTF.
I can't figure out how to delete the hyperlink the user clicked on, positioning the caret at the start of where the hyperlink was, then inserting the new RTF (the inserting is easy, the delete and positioning eludes me).
Thanks for any guidance, and sorry for missing something I should have found in your demos and Help documentation.
Eric
Replace hyperlink with new RTF?
-
- Site Admin
- Posts: 17852
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Replace hyperlink with new RTF?
Do you want to do it as an editing operation (undoable?)
If yes, just select the link and insert a new content. The selection will be replaced.
Let the caret is in the item that needs to be replaced, and the new RTF content is in Stream:
If yes, just select the link and insert a new content. The selection will be replaced.
Let the caret is in the item that needs to be replaced, and the new RTF content is in Stream:
Code: Select all
var
ItemNo, Offs1, Offs2: Integer;
rve: TCustomRichViewEdit;
// selecting the current item
rve := RichViewEdit1.TopLevelEditor;
ItemNo := rve.CurItemNo;
Offs1 := rve.GetOffsBeforeItem(ItemNo);
Offs2 := rve.GetOffsAfterItem(ItemNo);
rve.SetSelectionBounds(ItemNo, Offs1, ItemNo, Offs2);
// replacing it
Stream.Position := 0;
rve.InsertRTFFromStreamEd(Stream);
-
- Posts: 20
- Joined: Sun May 25, 2025 6:41 pm
Re: Replace hyperlink with new RTF?
Thanks, Sergey! Works great, and undo works fine as well on it.