I’ve been working on a complicated interactive SVG infographic, and I’ve learned I can use <$link> widgets to make ordinary <a> tags within it.
I’ve been trying to create the SVG element as something within the TiddlyWiki widget tree. So, I’ve been trying to create the tag using <$button tag="g">. But then the particular <g> curve doesn’t render.
Wrapping the <g> in a <$link>does work, and I understand that it creates a neutral <a> element wrapping the <g> element. But using <$link> I can only navigate to another tiddler. I can’t, as far as I know, set a field. So I’ve tried wrapping that link widget with a <$linkcatcher> widget, using its actions attribute to specify action widgets to be activated:
But, again, this causes the <g> tag that is wrapped by all of that not to render.
The best research I can achieve indicates that I have to separate the SVG from a button widget triggering the set-field action. I guess I’ll have to work on positioning that to appear to be part of the rest of the SVG image.
I have to assume that there’s something about the order of processing for the widget tree that is causing this behavior, but I can’t imagine a straightforward reason why a button widget can’t simply be a <g> tag. I’m really curious to know whether a single SVG approach, without a separated widget, is possible.
Something unexpected -at least for me- happens when I use this code in a new tiddler on tiddlywiki.com: clicking on red or blue circle not only displays default tiddlers like it should, but also creates a tiddler named “yyy” containing “xxx”.
As well as actions the linkcatcher can put the tiddler from the <$link> (xxx in the example) into a tiddler whose title is the value of the ‘to’ attribute, thus xxx get put inside yyy
Both your solutions work in that simple case, @buggyj, @XLBilly, thanks! But I’m not sure I understand this yet… also haven’t had a chance to test it in my full project yet, but let’s try this simplest test case:
That’s just the two circles, in separate <g> elements. So, say we need to be able to use one of those as a traditional link and the other to trigger our action:
However, this still doesn’t work because the $eventcatcher widget generates a SPAN element with class=“tc-eventcatcher”, which apparently interferes with rendering the blue circle within the enclosing SVG wrapper. You can avoid this problem by moving the $eventcatcher widget outside the entire <svg>...</svg> wrapper, like this:
Yes, wrapping the whole thing with the eventcatcher widget works file. It needs one refinement to be the ideal solution–a CSS definition, probably within a <style> element nested inside the <svg> element, to cause the mouse cursor to react as on a link.