changing hyperlink colors

  • (1) In the HyperlinkEvent I would like to change the color of the hyperlink text to indicate to the user that this hyperlink has already been selected. This behavior is consistent with web-browser behavior.

    How do I do this in the Hyperlink event code?

    (2) I want to prevent the user from being able to select the same hyperlink twice. What is the best way to mark the hyperlink so I can check to see if it was already selected? If the color is changed as indicated above, what code could I use to determine the current color of the clicked hyperlink in the HyperlinkEvent code?

    • Offizieller Beitrag
    Zitat von mphilbrick

    (1) In the HyperlinkEvent I would like to change the color of the hyperlink text to indicate to the user that this hyperlink has already been selected. This behavior is consistent with web-browser behavior.

    How do I do this in the Hyperlink event code?]

    Since there was no function for this I added one to unit WPRich.PAS. (Will be in V4.20a and later) If you paste the following code you can use it in the HyperlinkEvent:

    Zitat von mphilbrick

    (2) I want to prevent the user from being able to select the same hyperlink twice. What is the best way to mark the hyperlink so I can check to see if it was already selected? If the color is changed as indicated above, what code could I use to determine the current color of the clicked hyperlink in the HyperlinkEvent code?

    You can modify the code above to remove the afsHyperlink style. That would solve the problem, too : exclude(pa^.style, afsHyperlink)

    Julian

  • Thanks so much!

    I need to clarify the second part of my question ... actually, I want to keep the hyperlink active if the user has already selected it once. However, in the HyperLinkEvent I want to be able to determine if it has been selected already so I can display a warning message.

    Since I am changing the color, can I check the color within the code of the HyperLinkEvent? If so, what is the simplest way in code?

  • [1] I tried your new method, ModifyThisHyperLinkColor.

    It does change the color, because I can see the new color reflected in the color combo box when I place the cursor in the hyperlink text. However, the actual color of the hyperlink does NOT change. It appears that the hyperlink attributes override the underlying attributes.

    What am I doing wrong? My code:

    procedure TfmRecordBreaker.rtFormHyperLinkEvent(Sender: TObject; begin
    rtForm.ModifyThisHyperlinkColor(clFuchsia);
    end;

    [2] You may recall that I had a problem with the OneClickHyperlink option a few months ago. This new release does correct it as you told me. Thank you.

  • Zitat von wpsupport

    Okay, I FINALLY figured this out. I just set the text color of the hyperlink attribute manually when I used InputHyperlink and then I can change it. The TextAttr properties now make a lot more sense. Thank you.