//check if there is an hit
List list = getTextRuns(textNode);
//going backward in the list to catch the last character
// displayed at that position
TextHit hit = null;
for( int i = list.size()-1 ; i>= 0 && hit == null; i-- ){
StrokingTextPainter.TextRun textRun;
textRun = (StrokingTextPainter.TextRun)list.get(i);
hit = textRun.getLayout().hitTestChar(x,y);
}
if ( hit == null )
return -1;
//found an hit, check if it belong to the element
int first = getElementStartIndex( e );
int last = getElementEndIndex( e );
int hitIndex = hit.getCharIndex();
if ( hitIndex >= first && hitIndex <= last )
return hitIndex - first;
return -1;