xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: Determine clicked 'use' element
Date Thu, 29 Jan 2009 10:56:19 GMT
Hi Age,

Age Bosma <agebosma@gmail.com> wrote on 01/28/2009 02:43:51 PM:

> Age Bosma wrote:
> 
> > getTarget() Always gives me the referenced element if someone clicked
> > on the 'use' element and thus e.g. the id of the rect. This is fine if
> > someone actually clicked on the 'rect' element but I'd like to know
> > which 'use' element was clicked (the id of the use element) if someone
> > clicked on that.

   Well you can walk up the tree from the clicked element to the 
use element.  In Batik the elements are all basically normal DOM elements
(they should be SVGElementInstance references).  In anycase you should
be able to use 'getParentNode()' (java) or 'parentNode' (ecmascript) to
walk up the tree checking if the element is a use element or not.

   One problem you can run into in the 'general' case is that you don't 
know if it's the use element you really want, so I would suggest adding
a custom attribute that you can check for as you walk up the tree so you
know you have reached your element.

> > Using getCurrentTarget() instead of getTarget() always gives me the
> > 'svg' element, so that doesn't appear to be useful either.
> > 
> > How should one determine which 'use' element is clicked on?

Mime
View raw message