SVG anchor tag <a> support

I'm looking at using JUCE's SVG rendering rather than a web browser component in my juce_faustllvm module and in pMix2 to display faust SVG files. It seems that the <a> tag in an SVG causes SVGState::parseSubElement() to return a nullptr and everything inside the <a> tag is not drawn.

I have hacked this by modifying parseSubElement():

    Drawable* parseSubElement (const XmlPath& xml)
        const String tag (xml->getTagNameWithoutNamespace());

        if (tag == "a")           return parseGroupElement (xml);
        if (tag == "g")           return parseGroupElement (xml);

would it be possible to add proper anchor tag support?




Not sure about making them clickable, but are they basically just the same as a group element?

I'm afraid I don't know SVG well enough to say. It seems to work in the same way as a group element though. It would be great if there was some way to make them clickable, but I realise that is probably not doable within the context of a Drawable.

here is an svg that won't render the "noise" block in JUCE because it is within an <a>


I would like to have a crack at adding this and maybe supplying a patch. Could you let me know roughly what you think would be a good way to implement DrawableComposite::parseLinkElement() and catch clicks on <a> elements?


It's actually very tricky because there's no Drawable type which is a link. The nearest thing we have is DrawableText, but to do this it'd need to have extra functionality added so you can tell it to be a hyperlink, and that's really a bit uncomfortable in terms of the class's responsibilities.

(It could be done with a subclass of DrawableText, but that's also not good as those classes aren't intended to be inherited)

hmmm, maybe i will just have to parse the svg again seperately and do some mouselistener stuff for my purposes.