Hi,
I have a simple SVG document and want to receive MouseEvents in my Java code when a mouse click occurs on an element of the document. This works, as long as I have either a <desc> section or an <animateMotion ..> section in the document.
I tried this even with the following sample from the W3C SVG sites, because I first thought that my document has been wrong.
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="5cm" height="5cm" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<desc>Two groups, each of two rectangles
</desc>
<g id="group1" fill="red" >
<rect x="1cm" y="1cm" width="1cm" height="1cm" />
<rect x="3cm" y="1cm" width="1cm" height="1cm" />
</g>
<g id="group2" fill="blue" >
<rect x="1cm" y="3cm" width="1cm" height="1cm" />
<rect x="3cm" y="3cm" width="1cm" height="1cm" />
</g>
<!-- Show outline of canvas using 'rect' element -->
<rect x=".01cm" y=".01cm" width="4.98cm" height="4.98cm"
fill="none" stroke="blue" stroke-width=".02cm" />
</svg>
I have added a mouse listener to the group1 with:
SVGGElement group1 = (SVGGElement)svgDocument.getElementById("group1");
group1.addEventListener("click", new MouseClickListener(), false);
If I remove <desc> section in the document, the mouse events do no longer arrive in my code.
Does anyone have an idea about that ?
Yvonne Stöckle
___________________________________