How to display active website link with Graphics::drawText?

Hello,
Of course I know I can create own clickable component and on click call:

        URL url("https://www.example.pl");
        url.launchInDefaultBrowser();

But I wonder isn’t there anything simpler, like Graphics::drawText() but to tell in some way that it is clickable website link?

For any help great thanks in advance.

Best Regards

Have you had a look at JUCE: HyperlinkButton Class Reference?

To further the previous response: JUCE does not have richtext support that goes as far as mixing regular text with link text.

Also the Graphics class doesn’t itself deal with things like mouse clicks, that is Component level stuff.

Sorry I may have misunderstood the question at first.

It would be really cool if JUCE had a way to embed components in a string of text through juce::TextLayout and/or juce::AttributedString.

E.g. it would let you do things like this :wink: :raised_hands: which often get requested by our designers, but aren’t realistically feasible (without fixed-sizes, and/or horrible hacks).

Perhaps the next best thing would be to be able to retrieve the bounds* of a portion in the text.
With that, one could track where “this link” appears in the text and slap a transparent button on it for the action to be triggered.

*that could be a RectangleList rather than a single Rectangle, to cover the case of text spanning multiple lines

Clickable texts or visuals can be done with juce::Drawables, e.g. DrawableText.
That one is a Component, so you can attach a MouseListener to it, but I am not sure if I would want to go down that route. Drawables gave me pains once too often.

1 Like

Thanks for all reply. I have one more wonder. It’s not closely related to the main question, but little bit.

I wonder if is there any method which would allow me to draw html content.
I mean I would like to have on my server html file and I would like my juce application to connect to my server, download the html file and project it as a web page.

I see there is something like WebBrowserComponent, but I am affraid it is much more than I need.
I don’t wont any browsing actions like going to any url, or back/next actions. I just need to display simply html file.

Parsing and displaying HTML is incredibly complex.
WebBrowserComponent might be your best option, and it doesn’t display any control for navigation so you should be able to point it to an HTML file that you create locally and display it

1 Like