xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Slater" <dsla...@simulsoft.com>
Subject RE: EventListener does not respond to DOM mutations if added after document is loaded
Date Wed, 19 Nov 2008 20:04:17 GMT
Sorry for the unnecessary post.  Not a problem w/Batik at all, just my
lack of event knowledge.

For what it's worth...I was registering the listener directly on the
intended target.  However, I specified useCapture = true.  Reading the
w3c DOM spec (!!) revealed "A capturing EventListener will not be
triggered by events dispatched directly to the EventTarget upon which it
is registered." Setting useCapture = false solved the problem, the
listener fires now.

What appeared to work earlier was actually confusion with a similar
listener's debugging output, a result of inserting test code in the
wrong place :(

Dan

-------- Original Message --------
Subject: EventListener does not respond to DOM mutations if added after
document is loaded
From: "Dan Slater" <dslater@simulsoft.com>
Date: Wed, November 19, 2008 11:12 am
To: batik-users@xmlgraphics.apache.org

Hi,

I need to dynamically add or remove an EventListener when the user
clicks on an element displayed on a JSVGCanvas. I am trying to listen
to DOM mutations. If I use this code prior to calling setDocument, the
listener works after the document is displayed:

 EventTarget t = (EventTarget)elt;
 t.addEventListener("DOMAttrModified", anchorListener, true);
 parent.appendChild(typegroup);

However, when I add it during the interactive selection process, after
the document is already displayed in the JSVGCanvas, it doesn't work:

 public void setSelectedAttributes(SVGElement elt){
 elt.setAttributeNS(null, "selectionstate","selected");
 EventTarget t = (EventTarget)elt;
 t.addEventListener("DOMAttrModified", DX.anchorListener, true);
 }

Of course, the canvas is set to ALWAYS_DYNAMIC.

I must be missing a fairly basic concept or command. Can someone please
help?

Dan Slater


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message