That's the beauty of the DOM event listener - it gives a reference to
the element that has been clicked on. For example:

 public void handleEvent(Event evt) {
        if (evt instanceof org.w3c.dom.events.MouseEvent) {
            org.w3c.dom.events.MouseEvent e =
(org.w3c.dom.events.MouseEvent)evt;
            if (e.getDetail() == 1) {
              
                    // Single click on the SVG canvas
                    Element target = (Element)e.getTarget())
                 // target is our <circle>
                   
                }

In my application I use this conjunction with user data to display the
properties of the object that the circle represents.

Regards,
Matthew.
On Tue, 2008-01-22 at 22:08 +0200, Cojocar Cosmin wrote:
> Hello Matthew,
> 
>         I'm glad to hear that. I'm also curious about one problem.
> Maybe you have an idea.
>         If we have some small circle's on our canvas how can we obtain
> with a nice clean code a reference of one of them when clicked? We
> could search in dom tree document to see if our click is in some
> circle range, but maybe is there another solution. 
>         Also please paste your code here to share with others if you
> want :)
> 
> Regards,
> Cosmin
> 
> On Jan 22, 2008 9:55 PM, Matthew Wilson <[EMAIL PROTECTED]>
> wrote:
>         Hello Cosmin,
>         I did solve it in the end thanks! The link you posted pointed
>         me in the 
>         right direction. There were two things wrong I think:
>         
>         1. I was trying to register my listener too earlier - doing it
>         after the
>         SVGLoadEventDispatchStarted event works.
>         2. Batik doesn't dispatch any events if you click on a
>         whitespace region 
>         of the canvas. I added a transparent rectangle to my document
>         and
>         everything began to work!
>         
>         Thanks for your help, and good luck with your Batik
>         programming
>         Matthew.
>         
>         On Tue, 2008-01-22 at 21:47 +0200, Cojocar Cosmin wrote:
>         > Hello Matthew,
>         >
>         >         Did you solved your problem? because I'm new also
>         with batik
>         > and I made something like you wanted with awt listeners, but
>         after you 
>         > raised that problem I think I will try to change with
>         listener on
>         > jsvgcanvas directly.
>         >
>         > Regards,
>         > Cosmin
>         
>         
>         
>         
>         --------------------------------------------------------------------- 
>         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]

Reply via email to