xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Habib <hob...@gmail.com>
Subject Re: onClick event problem
Date Fri, 04 Sep 2009 07:05:13 GMT
Thank you Jonathan for you answer, but add point-events="none" to the text
element makes the whole box unresponsive to events. In case someone may spot
a problem, this is the code I use to add events:

NodeList nodeList = document.getElementsByTagName("g");
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node n = nodeList.item(i);
            String id = n.getAttributes().getNamedItem("id").getNodeValue();
            if (id.startsWith("node")) {
                Element elt = document.getElementById(id);
                EventTarget t = (EventTarget) elt;
                t.addEventListener("click", new OnClickAction(), false);
            }

Habib

On Fri, Sep 4, 2009 at 12:02 AM, jonathan wood
<jonathanshawwood@gmail.com>wrote:

> Hi Habib,
>
>   Just a shot in the dark, but maybe the text bbox is maskin the
> others....try adding pointer-events="none" to the text node and see if your
> events get bubbled as expected...
>
> also see http://www.w3.org/TR/SVG/interact.html#PointerEventsProperty
>
> If this is no help, just shout back to me or the list.  I'm new here also,
> so you may get better remedies later!
>
> jonathan
>
>
>
> On Thu, Sep 3, 2009 at 4:03 PM, Habib <hobbbo@gmail.com> wrote:
>
>> Hi all,
>>
>> i have an SVG file (generated by Graphviz) to which I want to script using
>> Java in order to add some event handling. The file is practically a set of
>> <g> elements which correspond to a text inside a box:
>>
>> <g id="node1" class="node">
>>     <title>node1</title>
>>     <polygon fill="none" stroke="black" points="343,-684 197,-684 197,-648
>> 343,-648 343,-684"/>
>>     <text text-anchor="middle" x="270" y="-661.9" font-family="Times
>> Roman,serif" font-size="14.00">node1 label</text>
>> </g>
>>
>> However, my problem is that I am adding event listener for an onClick
>> action on either the <g> or the <polygon> element (by srcipting with
java).
>> In either way, the event is triggered only if I click on the text (i.e. when
>> the mouse pointer changes to a cursor) and not when I click on the box. Am I
>> missing something? Thank you.
>>
>> Habib
>>
>>
>

Mime
View raw message