xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: Adding dynamic event handlers using position
Date Fri, 14 Apr 2006 01:56:22 GMT
Hi Selva,

news <news@sea.gmane.org> wrote on 04/13/2006 09:23:19 AM:

> When user presses the SVGCanvas, mousePressed event is finding the 
> element using the following code. Here I haven?t added event handlers 
for each 
> element since it will have more than 200 elements.

   You can register a single event handler on the root SVG element.  The
handleEvent method on this listener will be passed a DOMMouseEvent.  The
'getTarget()' will be the element the event mouse was over when the
mouse was clicked.

> Once I found the elements, I will add the event handlers for the 
elements in 
> the list. But these event handlers will work from the next mouse events. 
> resolve this, is it possible to simulate mousePressed event once again 
> manually after added the event listeners?

   Sure, but I'm not sure I understand why one would want to do this???
SVGDocument has methods to create and dispatch events.

> If this is not a better way, please provide some other way to add the 
> listeners for the elements dynamically?

   I would just add the one listener and sort out which element was 
in that (custom attributes on elements can be a big help here).

> Also is there anyway to select multiple elements in the SVG canvas? If 
it is 
> possible, how mouse listeners will work?

   You can not select multiple elements in the Canvas.  A DOM event has
exactly one target.  The get intersection list could return multiple 
and you could 'build' some form of multiple selection system using it but
DOM doesn't do this directly.

> Please give me the better solution to resolve these issues.

   I hope I have ;)

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

View raw message