You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Selva <se...@yahoo.co.in> on 2006/04/13 15:23:19 UTC
Adding dynamic event handlers using position
Hi All,
When user presses the SVGCanvas, mousePressed event is finding the clicked
element using the following code. Here I haven’t added event handlers for each
element since it will have more than 200 elements. Instead I am using
getIntersectionList.
SVGRect rect = svgCanvas.getSVGDocument().getRootElement().createSVGRect();
rect.setX((float)point.getX());
rect.setY((float)point.getY());
rect.setWidth(1);
rect.setHeight(1);
NodeList l = myroot.getIntersectionList(rect, null);
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. To
resolve this, is it possible to simulate mousePressed event once again
manually after added the event listeners?
If this is not a better way, please provide some other way to add the
listeners for the elements dynamically?
Also is there anyway to select multiple elements in the SVG canvas? If it is
possible, how mouse listeners will work?
Please give me the better solution to resolve these issues.
Thanks,
Selva
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Adding dynamic event handlers using position
Posted by Selva <se...@yahoo.co.in>.
Hi Thomas,
Thanks for your reply Thomas. It is very useful for me to work with event
handlers.
Thanks,
Selva
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Adding dynamic event handlers using position
Posted by th...@kodak.com.
Hi Selva,
news <ne...@sea.gmane.org> wrote on 04/13/2006 09:23:19 AM:
> When user presses the SVGCanvas, mousePressed event is finding the
clicked
> 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.
To
> 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
clicked
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
elements
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