Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8143158 [Text, TextFlow] Make public API from internal "impl" APIs
  3. JDK-8136346

[TextFlow] Expose API to obtain caret and selection shapes

    XMLWordPrintable

Details

    • Sub-task
    • Resolution: Fixed
    • P3
    • 9
    • 8
    • javafx

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              leifs Leif Samuelsson (Inactive)
              tmikula Tomas Mikula
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: