In reality, TextFlow implementation is buggy when it comes to handling of the surrogate pairs, as it requires character break iterator to skip over characters that represent a single unicode code point (see HitInfo.getInsertionIndex()). However, the text field is null, so the correct logic can not be implemented.
Also, it appears there is weird behavior in the Text.hitTest() inside a large emoji symbol: as one can see in the attached video: Text.insertionIndex() goes 0, 2, 1, 2 when moving the mouse across the symbol from the left edge to the right edge. (please create a new ticket if this is a separate issue).
A workaround might to scan TextFlow children to pick the right Text instance and then use its hitTest() method, though it might require a linear search and cause performance issues with long text flows.
edit: the workaround does not quite work, the reported position is incorrect in the case when multiple Text instances are added to the TextFlow.
SCCE to follow.
- blocks
-
JDK-8300569 ☂ Missing APIs related to rich text control
- In Progress
-
JDK-8301121 RichTextArea Control (Incubator)
- In Progress
- relates to
-
JDK-8304441 [macos] Crash when putting invalid unicode char on clipboard
- Resolved
-
JDK-8194704 Text/TextFlow hitTest() javadoc
- Resolved
-
JDK-8302511 HitInfo.toString() throws IllegalArgumentException
- Resolved
-
JDK-8308608 [testbug] Use Util::waitForIdle instead of Toolkit::firePulse in system tests
- Resolved
-
JDK-8306083 Text.hitTest is incorrect when more than one Text node in TextFlow
- Resolved