JDK-8319844 : Text/TextFlow.hitTest() is incorrect in RTL orientation
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: jfx21
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-11-09
  • Updated: 2024-10-15
  • Resolved: 2024-03-05
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
jfx23 b08Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Similarly to https://bugs.openjdk.org/browse/JDK-8319050, hitTest() is totally incorrect when node orientation is set to RIGHT_TO_LEFT.

To reproduce with the MonkeyTester https://github.com/andy-goryachev-oracle/MonkeyTest :
- select Text page
- select Failed Nav Bug text option
- select Window -> Orientation RTL from the main menu
Hover over the text displayed on the right side, notice that Text.hitTest label in the options panel is not updated.  Try hovering over where the text would be in LTR mode (on the left side).  Notice how hitTest label is getting updated.

The TextFlow also exhibits the same problem with its hitTest().
Also, a Text embedded in a TextFlow, seems to show a slightly different behavior, in which it does update Text.hitText label on hover, but the actual HitInfo is incorrect (try moving the mouse cursor across the text line).

The issue with TextFlow might be related to https://bugs.openjdk.org/browse/JDK-8318095
Comments
Changeset: 66d96818 Author: Karthik P K <kpk@openjdk.org> Date: 2024-03-05 04:04:16 +0000 URL: https://git.openjdk.org/jfx/commit/66d96818413f8ce5518cc20cff848eacd1a2d56c
05-03-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jfx/pull/1323 Date: 2024-01-09 07:31:51 +0000
09-01-2024

[~angorya] thanks for the details.
22-11-2023

[~kpk]: 1. The use case or RTL orientation is the use in one of the locales that use RTL language (Arabic, Hebrew, Urdu, etc.) The text direction is right to left, the UI elements are also arranged in the order of importance from right to left. You can see it by opening Wikipedia and changing the language to Arabic or Hebrew. 2. The function of hitTest() is to convert screen coordinates into text model coordinates. The screen coordinates are impacted by a switch to RTL, so hitTest() needs to take that into account. The orientation also impacts the reverse operation (from text model coordinates to screen coordinates), and these are caretShape(), rangeShape() in JDK-8319050 . Perhaps, as you look into these issues, we might want to check if any other methods are impacted by a switch to RTL orientation.
21-11-2023

[~angorya], I have couple of queries regarding this bug. 1. What would be the use case of setting the scene node orientation to RIGHT_TO_LEFT. I see that the hitTest() works as expected if scene node orientation is not changed. This includes only RTL text and combination of RTL and LTR text. 2. What is the expected behaviour of hitTest on changing the node orientation to RIGHT_TO_LEFT? The HitInfo values should be same as the value it returns when node orientation is LEFT_TO_RIGHT?
21-11-2023