Hyperlink underlined




I wanted my hyperlinkbutton to be underlined so I did the following modification in the HyperlinkButton::paintButton() method.

(As getFontToUse() is private, overriding is not simple to do... )


URL hyperlinks are underlined most of the time when you hover your mouse on, so I think it would be nice to have a flag in this class to set this behaviour.


void HyperlinkButton::paintButton (Graphics& g,
                                   bool isMouseOverButton,
                                   bool isButtonDown)
    const Colour textColour (findColour (textColourId));

    if (isEnabled())
        g.setColour ((isMouseOverButton) ? textColour.darker ((isButtonDown) ? 1.3f : 0.4f)
                                         : textColour);
        g.setColour (textColour.withMultipliedAlpha (0.4f));

    // old
    //g.setFont (getFontToUse());

    // new
    Font f = getFontToUse();
    g.setFont (f);

    g.drawText (getButtonText(), getLocalBounds().reduced (1, 0),
                justification.getOnlyHorizontalFlags() | Justification::verticallyCentred,




It's something that should probably eventually move into the L+F to make it more flexible - thanks for the heads-up!


Indeed I expected the hyperlink drawing to be in one of the look and feel methods.

Great. Look forward to it.