Hi Peppe,

Peppe <[EMAIL PROTECTED]> wrote on 12/12/2006 04:53:36 PM:

> when i click button "polygon" this activate 3 listener,
> initializing flag = true, create = true and elem = 6. 

   When you say 'activate' I suspect this means that you
add the listeners to the canvas.

> [everything works for first polygon]

>But when i reclick button "polygon" and then when i click 
> on svgCanvas the points is saved 2 times into string "points"...
> for example:
> insert first polygon
>     points = 192,168  340,430 ...
> when i reclick button polygon
>     points = 156,402  156,402  304,170  304,170 ....
> why?

    I think you end up registering a new instance of the
listeners when the user clicks 'polygon'.  You either need
to only register them once (and have a way to disable them
when they shouldn't do anything), or remove them after the 
polygon is created.

> private class OnDownAction implements EventListener {
>            public void handleEvent(Event evt) {
  [...]
> 
>                      points = points+startPt.getX()+","+startPt.getY()+" 
"; 
>                      System.out.println(points);

    Does this get printed twice for each point, like:
        156,402  156,402  304,170
        156,402  156,402  304,170  304,170

    I suspect you need to call 'EventTarget.removeEventListener'

Reply via email to