Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
This issue can be thought of as a subset of JDK-8092278 that can hopefully be implemented much sooner. The scope of this issue is solely hit test API (i.e. given the (x, y) coordinates, give me the position in text), *not* selection API a la DOM Range. It was possible to work around the lack of a hit test API using reflection and private (com.sun.*) API, but this workaround will stop working in JDK 9. A hit test must be able to determine the character that was hit, if any, and the insertion index (for caret positioning). I propose adding the following method to TextFlow: public HitInfo hitTest(double x, double y); where HitInfo has the following interface public class HitInfo { public OptionalInt getCharacterIndex(); public int getInsertionIndex(); } getCharacterIndex() returning OptionalInt allows to distinguish whether a character was hit at all (JDK-8091012). getInsertionIndex() should take character clusters (JDK-8092327 point 2.) into account. I implemented the hit test method in RichTextFX based on Felipe's suggestion (https://bugs.openjdk.java.net/browse/JDK-8091012?focusedCommentId=13795297&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13795297). It does not handle clusters, but I am happy to contribute the code.
|