Just to be clear, I’m doing this in Java, not the SVG-supported _javascript_.  Nonetheless, this drag tutorial seems to be precisely what I’m looking for.  Does it require _javascript_ (or anything else extra) to be present in the document?

 

Michael Bishop

 


From: Andres Toussaint [mailto:[EMAIL PROTECTED]
Sent: Monday, October 24, 2005 1:19 PM
To: [email protected]
Subject: Re: Efficient way of "selecting" an element?

 

SVG has the ability to dispatch events based on mouse actions, and the event holds the object that triggered the event (which is not necessarily the object holding the listener, in case it is a group), for example:

 

<g >

<rect id="object 1" ...../>

<rect id="object 2" ...../>

<rect id="object 3" ...../>

<rect id="object 4" ...../>

</g>

 

the event will be activated and dispatched only when the click is inside any of the rect objects, and the evt.target will tell you what is the clicked object.

 

You may also see the dragTutorial in the batik wiki to see how to add listeners in the code:

http://wiki.apache.org/xmlgraphics-batik/DragTutorial

 

regards,

Andres.

 

p.s. the same is true for all other mouse events.

 

On Oct 24, 2005, at 1:04 PM, Bishop, Michael W. CONTR J9C880 wrote:

 

I have a scenario where I’d like to click in the JSVGCanvas and “select” the SVG element I’m clicking inside of.  Short of iterating through the document and creating Java2D objects in which to check to see if my clicked point is “inside” of, is there a way in Batik to see which elements a point resides in?

 

Michael Bishop

Reply via email to