Hello Thomas, I was using a version 1.5. I downloaded the 1.5.1 version and now it works correctly.
Thanks for the hint. Jef. -----Original Message----- From: Thomas DeWeese [mailto:[EMAIL PROTECTED] Sent: maandag 15 maart 2004 19:02 To: Batik Users Subject: Re: dynamically adding events Hi Jef, What version of Batik are you using? There was a bug dealing with the dynamic addition of event handlers in "old" versions of Batik (however I think they were fixed in 1.5). Is it possible that the document has no 'dynamic' features prior to your adding the attributes. If so Batik will build the rendering tree for static display only. You can change this by calling "canvas.setDocumentState(ALWAYS_DYNAMIC)" _prior_ to loading the document. Also you should essentially never touch the DOM outside of the update manager thread (one of the very few/only(?) exceptions is that it is actually ok to touch it in response to most of the canvas callbacks, like buildCompleted, - probably not render/update completed). Verelst Jef wrote: > > Hello, > > I am trying to add event attributes (onclick, onmouseover, ...) to an > SVG. The code I use for it is this : > Element el = this.svgDoc.getElementById(id); > if(el != null) > { > el.setAttributeNS(null,attr,val); > } > > I get different results depending on the moment I call the code : when > called between loading and building, everything > works fine. The attribute is added and the event is attached (I can > change the value of the attribute later and the event > responds correctly). However, if I call this code after the rendering > completed (which unfortunately is the normal place > where my program gets to know the values of the attribute), the > attribute is added (I can get the value) but it does not > react to the mouse event... > > Besides the point of time where the setAttribute is called, I also see > that it is called in another thread. The first time I > call it in the [AWT-EventQueue-0] thread (who sends the update messages > concerning the loading and such). The second > time, I'm in my programs thread. > > Can anybody give me a hint on what is going wrong. If it is the thread, > is there a way of executing the setAttribute in > that thread (like it is with the update managers thread, by the way, > executing the add in the [RunnableQueue-0] thread > does not solve the problem). > > Thank you for your support. > > Jef --------------------------------------------------------------------- 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]