Page 1 of 1
more RVAction Hyperlink questions
Posted: Sat Feb 02, 2008 10:02 am
by toolwiz
There's an RVAction named rvActionInsertHyperlink1 that opens a dialog box when it's triggered (toolbar button and Insert | Hyperlink menu item). Where is that dialog box found?
There's a method RichViewEdit1_Jump(Sender: TObject; id: Integer) that's invoked if you click on a piece of text with a hyperlink set behind it through the above dialog box. (it's attached to the OnJump event on SRichViewEdit1.)
I'd like to make two changes in its behavior within SRV:
1) the mouseover of these items displays something in the status bar or a little pop-up hint to show what hyperlink is embedded in them;
2) the user needs to hold the CTRL key down to trigger the Jump method.
that is, I want something approximates what happens in MS Word.
Thanks
-David
Posted: Sun Feb 03, 2008 6:06 pm
by Sergey Tkachenko
This dialog is included in RichViewActions (HypRVFrm.pas). You can use your own dialog instead of it, use rvActionInsertHyperlink.OnHyperlinkForm event.
You can use OnItemHint event to display hints when mouse is above some item.
CTRL key is used by default.
Posted: Sun Feb 03, 2008 7:16 pm
by toolwiz
Sergey Tkachenko wrote:This dialog is included in RichViewActions (HypRVFrm.pas). You can use your own dialog instead of it, use rvActionInsertHyperlink.OnHyperlinkForm event.
You can use OnItemHint event to display hints when mouse is above some item.
CTRL key is used by default.
Thanks.
BTW, CTRL key is NOT used by default. When I create an embedded hyperlink that appears in SRV's RVE and left-click on it, it opens the browser to that link. No CTRL key needed. That's why I asked.
I suppose I can add a bit of code to the handler that opens the hyperlink to see if the CRTL key is down.
Do you know offhand what I need to call to check the current state of the CTRL key? (I always do it from inside of a keystroke handler, which passes them as params.)
Thx
-David
Posted: Thu Feb 07, 2008 7:31 am
by toolwiz
If is set a handler for OnItemHint in SRV, it never gets triggered.
-David
Posted: Thu Feb 07, 2008 6:44 pm
by proxy3d
If is set a handler for OnItemHint in SRV, then Hyperlink does not work?
Posted: Thu Feb 07, 2008 6:53 pm
by toolwiz
Yes, the hyperlink works; that's the OnJump handler. The OnItemHint handler is never triggered. I'd like to display the URL behind the link in the status bar.
Posted: Sat Feb 09, 2008 6:58 pm
by Sergey Tkachenko
I confirm this problem. Will be fixed.
Posted: Tue Feb 19, 2008 3:08 pm
by proxy3d
for OnItemHint:
Code: Select all
srv.RichViewEdit.Options := srv.RichViewEdit.Options + [rvoShowItemHints];
Posted: Tue Feb 19, 2008 5:16 pm
by toolwiz
Ok, thanks
It appears that the Hyperlink code that adds them to the item tags also encodes them -- apparently replacing spaces and punctuation with %xx forms. Is it necessary to do this when the hyperlinks are stored as tags? That is, can they be encoded later? (Do they need to be encoded at all?)
Alternatively, is there a DecodeURL function somewhere so when they're shown as hints they can be read by humans?
Thanks
-David
Posted: Tue Feb 19, 2008 5:24 pm
by Sergey Tkachenko
Hmm... Make sure that rvActionInsertHyperlink.SpaceFiller = ' '. In older version it was '%20' by default, but now it is changed.
rvActionInsertHyperlink does nothing with punctuation, but it removes #13 and #10 characters.
Posted: Tue Feb 19, 2008 7:13 pm
by toolwiz
Actually, if it finds CRs or LFs, it just sets Text = ''. But that's not a problem.
The question is ... is there any particular need to have encoded URLs stored in the Tags? I tried saving plain URLs and they're not being pulled up properly. But I'm not sure if it's because of that or something else. It's not really obvious to me how to work with the rvActionInsertHyperlink class for dealing with arbitrary text selections. It's set up to handle actions. In my case, I just need to read and set hyperlinks attached to text and images when the user makes certain selections in a dialog box. It's kind of like the Hyperlink dialog box, but I can't just pop it up the way that the Hyperlink dialog box is. You're not adding a hyperlink; rather, you setting some properties, and if there's a hyperlink specified (or not) among those properties, then it needs to be set (or cleared).
-David
Posted: Thu Feb 21, 2008 4:37 pm
by Sergey Tkachenko
You can look in RichViewActions.pas, TrvActionInsertHyperlink.EncodeTarget.
You will see that
1) it deletes CR and LF characters from target;
2) if SpaceFiller property does not contain space character, it changes all spaces to SpaceFiller.
(1) is absolutely necessary, otherwise this link cannot be stored in RVF. In any case, the standard RichViewActions hyperlink dialog does not allow entering multiline targets.
(2) is not necessary any more (in very old versions, tag strings could not contain space characters). So SpaceFiller=' ', and no processing occurs.
That means, target entered in the hyperlink dialog is stored as it is, without any modification. If in your application it is not so, please give the step-by-step instructions how to reproduce the problem.