RFR: 8319844 : Text/TextFlow.hitTest() is incorrect in RTL orientation [v11]

Karthik P K kpk at openjdk.org
Thu Feb 22 06:44:03 UTC 2024


On Wed, 21 Feb 2024 18:59:02 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

> 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?
> 
Yes there will be one TextRun at a certain x/y coordinate.
Consider following case where "First text." and "Second text" are 2 Text nodes embedded in TextFlow. Cursor is placed on the first character of the second text as shown in the screenshot. Now if the x/y coordinates are relative to TextFlow we can map it to second text in `getHitInfo` method of `PrismTextLayout` with only the help of x/y coordinates but we will not have information to decide if the character index should be calculated relative to Text node or TextFlow.
On the other hand if the x/y coordinates are relative to Text node, we will not have information to decide if the hit test was requested on first text or second text.
<img width="668" alt="Screenshot 2024-02-22 at 11 41 46 AM" src="https://github.com/openjdk/jfx/assets/26969459/8b1d1a90-9501-4149-b23b-6bc90a34f07b">


> 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()` ?
>
 
Again in this case, the above challenge will be there. On top of that we need to decide how much of the same text is present in the previous line. If we are calculating for TextFlow we can easily do this with the help of start value of the TextRun but when we need to calculate the character index relative to the Text node, we will not be able to decide without additional parameters. The `getText()` gives the entire text of the TextFlow rather than the text content of the Text node on which the hit test is requested.
If the same text is present in previous node as well, then we will not be able to decide from which TextRun, the calculation should start. For this reason we need run start value of the current line and current Text node.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1323#issuecomment-1958804257


More information about the openjfx-dev mailing list