Page 1 of 1

Issue when setting up a Hyperlink to Image

Posted: Fri May 05, 2017 8:37 am
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 9410 times

Re: Issue when setting up a Hyperlink to Image

Posted: Sat May 06, 2017 6:49 pm
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.