I checked out the lastest CVS and am trying that. The root of the problem seems to be that I'm getting negative numbers from MouseEvent.getClientY when I point at the center of the text. This seems wrong. Shouldn't I only get positive values since they are with respect to the upper left of the canvas?
BTW: Here is the SVG that I'm using: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [ ]> <svg width="220" height="60" viewBox="0 0 220 60"> <text id="expression.0" transform="matrix(1 0 0 1 0 20)">if (true or false) then {'foo'} else {'bar', 'zip'}</text> <text id="result.0" transform="matrix(1 0 0 1 0 40)">result</text> </svg> ----- Original Message ----- From: "Thomas DeWeese" <[EMAIL PROTECTED]> To: "Batik Users" <[EMAIL PROTECTED]> Sent: Wednesday, August 20, 2003 5:03 AM Subject: Re: getCharNumAtPosition trouble > Denis Bohm wrote: > > 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: > > This I believe is because you should use getClientX/Y not screenX/Y. > Rereading the spec it is unclear which coordinate system getScreenCTM should > transform to (clientX/Y has 0,0 at the upper left of the canvas, screenX/Y > has 0,0 at the upper left of the physical device). > > I will send a question to the SVG Working Group on this to get a clarification > of what is the correct answer. > > > 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? > > There was a bug in getExtentOfChar which I just fixed in CVS. You can > check the commit message to get the patches, or just use CVS to update. > > > > --------------------------------------------------------------------- > 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]