On Wed, 21 Feb 2024 13:03:46 GMT, Karthik P K <k...@openjdk.org> wrote:
> > To determine the runStart/runEnd, `Text` is already analyzing the runs (and > > doing coordinate tests on them). Runs however have locations, with x/y > > coordinates. Would it not be possible, and more sensible, to adjust the > > `x`, `y` coordinates passed to `getHitInfo` instead of leaving those as > > coordinates relative to the `Text` ? I mean, you are using the parents > > `TextLayout`, so it would make sense to pass that `TextLayout` coordinates > > that are correct for it in the first place? > > I'm afraid we can't do this. Primarily because if we pass `TextLayout` > coordinates in the case of Text node embedded in TextFlow, we do not know if > the character index needs to be calculated relative to the Text node or for > the entire TextFlow. There is no way we could figure out this case without > the extra parameters. Also if we do not pass the start value of the TextRun > on which hit test is requested, there is no way to figure out on which Text > node it is requested when same Text is repeated in the TextFlow. I'm unclear on this part, do you mean it's possible that multiple `Text` objects could be hit at the same time? There should only be one `TextRun` at a certain x/y coordinate right? > For the case like wrapped Text node inside TextFlow, we need to have text > value, otherwise we can't determine if the same text is present in the > previous line. If the `Text` is wrapped, there will be multiple `TextRun`s. The coordinate given will match to one of the runs. The run then has a link back to a `TextSpan`, which has a `getText()` ? > So I believe we need these extra parameters to calculate the hit info for all > the cases. Okay, well, we have some good new tests, so perhaps I'll play with it a bit to see what it is possible. ------------- PR Comment: https://git.openjdk.org/jfx/pull/1323#issuecomment-1957709245