$linkcatcher doesn't work with SVGs

41 views
Skip to first unread message

c pa

unread,
Sep 4, 2018, 10:50:59 PM9/4/18
to TiddlyWiki
Here's the code. This demonstrates that linkcatcher does not catch links sent from within an SVG diagram. Is there a work-around (other than using foreignObject and buttons) ?

\define linkaction()<$action-setfield $tiddler=<<currentTiddler>> $field="curitem" $value="u"/>

<$linkcatcher actions=<<linkaction>> >
<svg stroke="black" fill="white" fill-opacity="0" width="100" height="100">
    <a href="#ggg"><rect x=1 y=1 width=20 height=20 /></a>
</svg>
</$linkcatcher>

<$linkcatcher actions=<<linkaction>> >
[[ggg]]
</$linkcatcher>

{{!!curitem}}

<$button set="!!curitem" setTo="X">reset</$button>


PMario

unread,
Sep 5, 2018, 2:21:04 AM9/5/18
to TiddlyWiki
Hi,

That's not how the mechanism works. Link-catcher needs to be initialized with a link-widget, which also creates a TW click-event-handler. eg: [[ggg]] or <$link ... >

Rendering an svg that contains an <a> element creates a standard HTML element, which isn't touched by TW. The href link will be catched by the browser.

You may be able to experiment with the: Making Cureved Text example. Which uses a different mechanism to create the svg code ... BUT I didn't try it, so it may not work ...

The working example can be found at: https://tiddlywiki.com/#Using%20SVG which uses the foreignObject. 

The svg use-mechanism may be an option too.  https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use ... I didn't test it!

If you can't use the documented examples, you'll need to run your own tests. ... And please let us know, what works, if it works ;)

have fun!
mario

Jed Carty

unread,
Sep 5, 2018, 3:22:04 AM9/5/18
to TiddlyWiki
You can switch it to use a link widget like this:

\define linkaction()<$action-setfield $tiddler=<<currentTiddler>> $field="curitem" $value="u"/>

<$linkcatcher actions=<<linkaction>> >
<$link to="ggg">
<svg stroke="black" fill="white" fill-opacity="0" width="100" height="100">
<rect x=1 y=1 width=20 height=20 />
</svg>
</$link>
Reply all
Reply to author
Forward
0 new messages