...did you try event.getClientX() and event.getClientY() ?
Also, if you getNodeValue() of 'text' is it really the right text?

-randy

-----Original Message-----
From: Denis Bohm [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 19, 2003 11:23 PM
To: Batik Users
Subject: getCharNumAtPosition trouble

I'm trying to track the cursor movement across some text to highlight
the
character that the cursor is over.  In my svg I have a text element that
contains a tspan element.  I tried the following on mousemove for the
text,
but always get -1 for the character index:

        SVGTSpanElement text = (SVGTSpanElement) event.getTarget();
        SVGTextElement parent = (SVGTextElement) text.getParentNode();
        SVGMatrix transform = parent.getScreenCTM();
        SVGMatrix inverse = transform.inverse();
        SVGDocument document = canvas_.getSVGDocument();
        SVGSVGElement root = document.getRootElement();
        SVGPoint point = root.createSVGPoint();
        point.setX(event.getScreenX());
        point.setY(event.getScreenY());
        point = point.matrixTransform(inverse);
        int index = text.getCharNumAtPosition(point);
        System.out.println(index);
        SVGRect extent = parent.getExtentOfChar(0);
        System.out.println(extent.getX() + " " + extent.getY());

So I tried the following, which also gives -1:

        point.setX(extent.getX() + 1);
        point.setY(extent.getY() + 1);
        index = parent.getCharNumAtPosition(point);
        System.out.println(index);

Any idea what I might be doing wrong?

Thanks,
  Denis


---------------------------------------------------------------------
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