JDK-8306083 : Text.hitTest is incorrect when more than one Text node in TextFlow
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: jfx19
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2023-04-17
  • Updated: 2023-10-26
  • Resolved: 2023-10-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
jfx22 b15Fixed
Related Reports
Blocks :  
Relates :  
Description
When hitTest() is invoked for the Text node in a TextFlow with more than one Text child, the character index and the insertion index values obtained are not correct.

User monkey tester app to reproduce the issue: https://github.com/andy-goryachev-oracle/Test/blob/main/src/goryachev/monkey/MonkeyTesterApp.java

Steps to reproduce the issue:
1. Open Monkey Tester app and select TextFlow.
2. From Text dropdown on the right side, select Rich Text and Font Size 48.
3. Start hovering mouse on the text "BOLD" and observe the hitTest values of Text on the right side. When the mouse is hovered over trailing side of "O", character index returned is 2 which should have been 1. When cursor is hovered over letter "D", character index returned is 5 whereas expected char index is 3.

The issue is because of the bug in the logic of looping through the array of text runs in getHitInfo method of PrismTextLayout.java which results in calculating character index value using wrong text run for the given Text node.

Comments
Changeset: 929035f1 Author: Karthik P K <kpk@openjdk.org> Date: 2023-10-21 07:17:19 +0000 URL: https://git.openjdk.org/jfx/commit/929035f1857d961c0a9b7b281052aace3da837cc
21-10-2023

Thanks for updating the details [~angorya].
21-09-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jfx/pull/1157 Date: 2023-06-21 06:34:00 +0000
21-06-2023

[~vdyakov], wanted to clarify if this bug should contain test_sprint label since this is not a test_bug. It is filed as a followup to JDK-8304831.
18-04-2023