This is related to JDK-8092278 and JDK-8130362, but asks for much less. While those tickets ask for selection/cut/copy/paste functionality to be implemented by TextFlow, here I want to ask to only expose low-level methods to obtain the selection/caret shape (for a given range/position).
This is all it takes to implement those methods in TextFlow.java (see also the attached patch against 9-dev):
public PathElement[] getCaretShape(int charIdx, boolean isLeading) {
return getTextLayout().getCaretShape(charIdx, isLeading, 0.0f, 0.0f);
}
public PathElement[] getSelectionShape(int from, int to) {
return getTextLayout().getRange(from, to, TextLayout.TYPE_TEXT, 0, 0);
}
This, together with a hit-test API (JDK-8090357, JDK-8091012) allows users to implement such higher level functionality as selection, copy&paste, editing...
I have implemented the equivalents of the above methods in RichTextFX using reflection and com.sun.javafx.scene.text.TextLayout, and implemented selection and editing on top of them. This request is prompted by the fact that starting with JDK 9, com.sun.* APIs will not be accessible.
My hope is that this could be targeted for 9.
This is all it takes to implement those methods in TextFlow.java (see also the attached patch against 9-dev):
public PathElement[] getCaretShape(int charIdx, boolean isLeading) {
return getTextLayout().getCaretShape(charIdx, isLeading, 0.0f, 0.0f);
}
public PathElement[] getSelectionShape(int from, int to) {
return getTextLayout().getRange(from, to, TextLayout.TYPE_TEXT, 0, 0);
}
This, together with a hit-test API (
I have implemented the equivalents of the above methods in RichTextFX using reflection and com.sun.javafx.scene.text.TextLayout, and implemented selection and editing on top of them. This request is prompted by the fact that starting with JDK 9, com.sun.* APIs will not be accessible.
My hope is that this could be targeted for 9.
- relates to
-
JDK-8119007 Text.getImpl_caretShape() returns wrong shape when Text is not the first child of TextFlow
- Closed
-
JDK-8136573 Review (and possibly make public) candidate API from private APIs
- Resolved
-
JDK-8130362 Support for select text, cut, copy & paste
- Open
-
JDK-8092278 Text should have API for selecting group of characters based on their position similar to the DOM's Range.
- Closed