xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas DeWeese <Thomas.DeWe...@Kodak.com>
Subject Re: When to register EventListeners?
Date Sat, 11 Oct 2003 00:14:47 GMT
Reinhard Brandst├Ądter wrote:
> Hi!
> I'm just playing around with Java Scripting and Event Handling but I 
> think I'm missing a basic understanding of when to register event 
> Listeners.
> When I create a whole dom tree document is it possible to register 
> listeners when I create and add elements to the tree so that the 
> listeners can handle events as soon as the DOM is rendered in a canvas?

   Yes, you should be able to register listeners before the Document
is associated with the Canvas.

> jSVGCanvas1.setURI(uri);
> ...
> while (cond) {
> Element elem = <getElement Object here>
> EventTarget target = (EventTarget)elem;
> target.addEventListener("OnMouseOver",new OnMouseOverAction(),false);
> target.addEventListener("OnMouseOut",new OnMouseOutAction(),false);
> doc.getRootElement().appendChild(gelem);'

    This confuses me a little why are you appending the element.
Are you constructing the document "on the fly"?

> }
> //then set the Canvas to display doc
> canvas.setSVGDocument(doc);

    Why are you resetting the document?  If doc is the document
read from URI then all your modifications are already being tracked.
When you add an element it is added to the rendering tree, etc.

> I think calling setSVGDocument() after I've created the document 
> "offline" isn't the right way but how can I use the updateManager to 
> replace the whole document in the Canvas with the new one?

    The whole idea of the updateManager is that it tracks the changes
to the document as you make them.  One consequence of this
is that it can be faster to make all your changes up front rather
than have them tracked 'live'.

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

View raw message