xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Barbisch, Martin" <barbi...@sony.de>
Subject evt.getClientX/Y() discrepancy between Batik and Adobe's SVG View er.
Date Thu, 20 Jun 2002 15:33:41 GMT
Hi everybody!

I am a little confused about getClientX() and getClientY(). Should these
functions always return the x and y coordinate relative to the origin of the
canvas? Or should they deliver coordinates relative to the "object" the
mouse currently is over? (e.g. nested <svg> elements or a <use>d <symbol>
with its own viewBox attribute setting)

When displaying the included SVG file with Batik I get the following
When the mouse pointer is over the green rectangle (but NOT over the text)
the coordinates are relative to the canvas origin. When the mouse pointer is
over the text "Text" they are relative to some bounding box of the text.

Using Adobe's SVG Viewer the coordinates are always relative to the canvas

Bug or feature? :-)


[Batik 1.5 Beta 3, JDK 1.4.0_01, Windows 2000]


<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"

<svg width="300" height="300" onmousemove="showCoordinates(evt)">

  <script type="text/ecmascript"> <![CDATA[

    function showCoordinates(evt) {

        var status  = document.getElementById("Status");
        var newText = document.createTextNode("x: "   + evt.getClientX() +
                                              "  y: " + evt.getClientY());

        status.replaceChild(newText, status.getFirstChild());

  ]]> </script>

    <symbol id="Rect" preserveAspectRatio="none" viewBox="0 0 100 100">
      <rect x="0" y="0" width="100" height="100"
            style="stroke:yellow; fill:green;" />
      <text x="50" y="70"
            style="text-anchor:middle; font-size:30pt; fill:yellow">

  <use xlink:href="#Rect" x="30" y="30" width="200" height="150" />

  <text id="Status" x="20" y="250">x: ---  y: ---</text>

  <text x="150" y="290" style="text-anchor:middle; font-size:20pt">
    getClientX/Y() Problem.


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

View raw message