Hi there,
elt.getElementsByTagName returns NodeList, I tried this but nothing
happens, btw are the red circles suppose to appear clickable?
NodeList circleElement = elt.getElementsByTagName("circle");
Thx
yasmin
> Hi Yasmin,
>
> your code sample was:
>> Element element = doc.getElementById("circleGroup");
>> EventTarget eventTarget = (EventTarget) element;
>> eventTarget.addEventListener("click",new CircleAction(),false);
>>
>>
>> class CircleAction implements EventListener
>> {
>> public void handleEvent(Event evt)
>> {
>> Element elt = (Element) evt.getCurrentTarget();
>>
>> if (evt.getType() == "click")
>> {
>> elt.setAttributeNS("circle","fill","yellow");
>> }
>> }
>
> In here, you add a listener to a group(?) and afterwards, when the group
> is clicked, try to set the attribute "fill" on the element "elt" in the
> namespace "circle" to yellow.
> Instead, what (I believe) you want to do is to set the attribute on the
> element circle.
> I have not tested it (and am not familiar with the W3C DOM API either,
> using dom4j mainly), but maybe you could change the listeners code to:
>
> > Element elt = (Element) evt.getCurrentTarget();
> > Element circleElement = elt.getElementByTagName("circle")
> > if (evt.getType() == "click") {
> > circleElement.setAttributeNS(null,"fill","yellow");
> > }
>
> Oh, and maybe check for the eventtype before doing anything else,
> possible saving some time at runtime.
>
> I've not followed your discussion in detail,
> but maybe you can have a look at this class from my project:
> http://cvs.sourceforge.net/viewcvs.py/anathema/CharmTree/src/net/sf/anathema/charmtree/listening/CharmTreeListening.java?view=markup
>
> Within, you'll find two EventListeners,"cursorTooltipInitListener" and
> "selectionInvokingListener". The former acts on mouseover, but the
> latter reacts on mouseclick events for the element it's over.
> Within, the first part retrieves the target element.
> (Ignore the special case of an TSpan-Element being clicked)
> Then, an element ID is read from the synonymous attribute,
> finally, an event is fired.
>
> Basically, you could use this (or very simliar code) for parsing the
> document whenever a click event occurs and locating the target element
> by hand, thus making sure you got the circle and only the circle to
> operate upon.
>
> I guess they're way to complicated for what you intend to do, but maybe
> they can help you figure out how to do it by stripping things away.
>
> Good luck with your task
> -Urs
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]