xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: MouseEvnts in scrolled Canvas
Date Tue, 11 Apr 2006 16:15:22 GMT
Hi Henric,

"Henric Rosvall" <henric.rosvall@swipnet.se> wrote on 04/11/2006 11:15:35 

> So, how do I convert the ClientX and ClientY-coordinates into canvas-
> coordinates? (so a click at position 200, 300 with a JSVGScrollPane 
> down 500 px becomes 200, 1000)

   I presume you mean 200,800.  The short answer is getScreenCTM().
If you look at the recent message from Selva, there is a good example
of how to use this in the 'localPt' function.  For all of SVG it is 
important to have a clear idea of what coordinate system you are working
in.  For updating the X/Y coordinates of an element they are defined in
the 'local' coordinate system of the element (which is often but not 
the same as the parent's coordinate system, if the element has a 
attribute then it is likely not the same).

> I have a class that inherits from JSVGCanvas, encapsulated in a 
> JSVGScrollPane. When I click somewhere in the canvas, I get a 
> that reports the clientX and Y-coordinates, and this works great - if 
> JSVGScrollPane isn't scrolled. If I scroll down, it will still report 
the same 
> coordinate as when it's not scrolled at all, which causes a problem when 

> trying to select an object.

   BTW you should check if you can use the 'target' that is already in the
MouseEvent as that is the element the mouse is over when the event was 
For most uses this is exactly what you want.

To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

View raw message