The RichTextArea control (JDK-8301121), or any custom control that need to render a custom text caret (such as caret that displays some sort of direction indicator) can benefit from a better public API representing the caret.
Currently, the caret is represented as by array of PathElements in an undocumented fashion; the reverse engineering shows that it's either a single line encoded as [MoveTo,LineTo], or two lines in the case of "split caret" (a situation corresponding to the caret being at the border of RTL and LTR text where the insertion point depends on the type of character that gets inserted). As a result, the code, both internal and external, is peppered with constructs like
if(pathElements.length == 4)
which isn't great.
One possibility is to add a new method to Text / TextFlow:
public CaretInfo getCaretInfo(int charIndex, boolean leading)
The other is to add this method to the LayoutInfo object obtained from Text/TextFlow added by JDK-8341670.
The CaretInfo class would provide the following data points:
- getLineCount()
- getLineAt(int part)
The RichTextArea requires such a public API in TextFlow only, but we'll basically get the same functionality for Text node for free.
Currently, the caret is represented as by array of PathElements in an undocumented fashion; the reverse engineering shows that it's either a single line encoded as [MoveTo,LineTo], or two lines in the case of "split caret" (a situation corresponding to the caret being at the border of RTL and LTR text where the insertion point depends on the type of character that gets inserted). As a result, the code, both internal and external, is peppered with constructs like
if(pathElements.length == 4)
which isn't great.
One possibility is to add a new method to Text / TextFlow:
public CaretInfo getCaretInfo(int charIndex, boolean leading)
The other is to add this method to the LayoutInfo object obtained from Text/TextFlow added by JDK-8341670.
The CaretInfo class would provide the following data points:
- getLineCount()
- getLineAt(int part)
The RichTextArea requires such a public API in TextFlow only, but we'll basically get the same functionality for Text node for free.
- is cloned by
-
JDK-8341672 [Text/TextFlow] getRangeInfo
- Open
- relates to
-
JDK-8300569 ☂ Missing APIs related to rich text control
- In Progress
-
JDK-8301121 RichTextArea Control (Incubator)
- In Progress
-
JDK-8341670 [Text,TextFlow] Public API for Text Layout Info
- In Progress
- links to
-
Review(master) openjdk/jfx/1596