Hi Oliver, "HODAC, Olivier" <[email protected]> wrote on 10/27/2009 12:51:13 PM:
> I succeded in catching the event. Thanks, thomas, I had forgot the > ALWAYS_DYNAMIC state. > The solution of Heidrun is the solution I have implemented as it > seems that the evt.getTarget() seems not to point on the right node > (in the case I use refs to symbols, see SVG). Do you know why? The > getTarget() is not the right method to call? Well getTarget will point at the actual geometry element (like a rect, text, or in your case a polygon). In cases like this I normally walk up the tree until I get to the desired element (see 'getParent' on DOM Elements). I'll often add an attribute in a custom namespace rather than simply assume that the first symbol is the right element. > When I write the following piece of code, I point on the polygon > Node of the SVG which is the symbol element (=> no ID => > NullPointerException). I want to get the use element (top, bottom or > middle of the SVG) One thing to watch for is that the element it points at will be in a 'shadow tree' (a copy we make so we can properly perform the CSS cascade). So you need to do some fancy footwork to navigate across the symbol->use boundary (see batik.dom.svg.SVGOMUseShadowRoot.getCSSParentNode).
