Hello to everyone,
 
does anybody got an idea how to add an MouseEventListener to the JSVGCanvas which gets the correct SVG coordinates??
 
I want to do the following: I've got an element in the canvas and want to move it by mouseclick. So far I can drag and drop the element with the "mousedown", "mousedown" and "mousemove" events... but if I move the mouse quickly it seems as if Batik or my computer is too slow, and the cursor is not anymore over the element and the events get not called anymore.
So my idea was to add an "mouseup" event to the canvas, but the following code returns different coordinates for the canvas-MouseEvent and the DOMMouseEvent...
 
the canvas Listener:
canvas.addMouseListener(new MouseListener(){
   public void mouseReleased(MouseEvent e) {
      }
});
 
the DOMEventListener:
- initialization:
Element root = document.getElementById("e");
SVGGElement target = (SVGGElement)root;
target.addEventListener("mousemove", new MouseMoveListener(), true);
 
- class implementation:
public class MouseMoveListener implements EventListener {
    public void handleEvent (Event evt) {
      DOMMouseEvent pos = ((DOMMouseEvent)evt); 
}
}
 
Does anybody have an idea how to get the correct position from the canvasListener??
 
Thank you very much in advance...
Michael H�ndel.

Reply via email to