Hi Andre, I think the problem is that you need to tell the Canvas to be interactive/dynamic. If the Canvas looks at the document and doesn't see any dynamic content it uses a quicker lower memory build that doesn't support event handlers at all.
Check out FAQ 3.2: http://xmlgraphics.apache.org/batik/faq.html I had no idea what the problem was for quite some time since the difference isn't between clicking on a 'g' or an 'a' element it's between a document that has 'a' element or a document that doesn't have an 'a' element. André de Brito <andre.br...@evolve.pt> wrote on 02/16/2011 04:48:44 PM: > I'm using batik to display SVG files on a JSVGCanvas and I'm trying > to respond to mouse click events over SVG elements with tags <a> > (SVGOMAElement) and <g> (SVGOMGElement). > Here is the code I'm using to add the event listener to a Node: > > if ((no.getNodeName().equalsIgnoreCase("a")) || (no.getNodeName > ().equalsIgnoreCase("g"))) { > EventTarget etr = (EventTarget) no; > etr.addEventListener(SVGConstants.SVG_EVENT_CLICK, new EventListener() { > public void handleEvent(Event evt) { > Log.debug("HANDLE EVENT"); > } > }, false); > > What happens is that the listener is correcly called when an <a> > element is clicked, but nothing happens when a <g> element is clicked! > I debuged the code above and verified that the "click" listener is > being added to the both node's bubblingListeners table > (etr->eventSupport->bubblingListeners). However, I noticed that the > <a> elements seem to have two other (default) listeners - for events > "mouseout" and "mouseover" - which are not present on the <g> > elements. I don't believe this is the cause, but ... > > Any ideas on what could be causing this behaviour? Thomas DeWeese | CDG Advanced Development | Eastman Kodak Company | 343 State Street | Rochester, NY 14650-0128 | thomas.dewe...@kodak.com | 585 724-0294 | www.kodak.com