Issue when setting up a Hyperlink to Image

General TRichView support forum. Please post your questions here
Post Reply
aslius1
Posts: 1
Joined: Fri May 05, 2017 8:18 am

Issue when setting up a Hyperlink to Image

Post by aslius1 »

Dears, we've found an issue 'List out of bounds' when adding hypelink to Image

Steps to reproduce :
On empty richview add image from clipboard.
then select image and press 'Add hyperlink' , then poppup windows will appaered, type any text in URL and press ok, Error message will appeared

This part of code "rve.GetItem(rve.CurItemNo+1).ItemText" gives an issue due there is only one element
I suspect there should be a check if rve.CurItemNo+1 is inside bounds

1882.png
1882.png (167.66 KiB) Viewed 9398 times
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Issue when setting up a Hyperlink to Image

Post by Sergey Tkachenko »

Hello,

This is not an original version of RichViewActions.pas, I can see it contains modifications that were not added by us.
Also, I can see, changes were made in older version of RichViewActions (In the new version of RichViewActions, procedure TrvActionInsertHyperlink.ExecuteTarget starts from the line 7578)

As I can see, the purpose of your modifications was to synchronize visible text and hypertext target. It is really useful for URLs, and RichViewActions do not do it.
Ok, I'll implement in the next update: if a single text item is selected, and its visible text is the same as its tag, this action will change both visible text and tag.
If you need an opposite operation as well (changing tag when visible text is edited), see how it is implemented in the demo Demos\DelphiUnicode\Assorterd\Hypertext\URLs (OnItemTextEdit even).

Also, there is a very simple alternative solution. It is used, for example, in Help and Manual. You can reserve some special tag value (Help and Manual uses '<%LINK_CAPTION%>'). If tag is equal to this value, it is assumed that the link target must be taken from visible text of the hyperlink.
Post Reply