Hi, JabRef [0] uses the incubator CodeArea for its BibTeX source editor.
We would like to support the macOS text-editing shortcut Ctrl+L, which scrolls the view so that the caret line is vertically centered without moving the caret [1]. This is the use case of JDK-8380073 [2]: positioning a given text position at a defined place in the viewport. For TextArea, this works with public API: - TextAreaSkin#getCaretBounds() [3] - TextArea#setScrollTop(double) [4] For RichTextArea [5] (checked in 27 and 28-ea+12), the public API offers no caret or character bounds, no scroll position, and no "scroll into view" function. Only getTextPosition(x, y), getDocumentArea(), and pageUp()/pageDown() are available. The functionality exists internally in the non-exported VFlow (source at commit c641387 [6]): - VFlow#getCaretInfo() [7] - VFlow#scrollVerticalFraction(double) [8] - VFlow#scrollToVisible(double, double) [9] - VFlow#scrollCaretToVisible() [10] Public methods in RichTextArea [11] would cover this use case. For example: - Bounds getCaretBounds() (or bounds for an arbitrary TextPos), in local coordinates, like TextAreaSkin#getCaretBounds(). - A way to scroll so that a TextPos is shown at a given relative vertical position, e.g. scrollToPosition(TextPos pos, double fraction), with 0.0 = top, 0.5 = center, 1.0 = bottom. The 0.0 case covers JDK-8380073, while 0.5 covers caret centering. Thanks for the RichtText control so far; the control works great! Best regards, Christoph ------------------------------ References: [0] https://github.com/JabRef/jabref [1] https://github.com/JabRef/jabref/issues/17771 [2] https://bugs.openjdk.org/browse/JDK-8380073 [3] https://openjfx.io/javadoc/25/javafx.controls/javafx/scene/control/skin/TextAreaSkin.html#getCaretBounds() [4] https://openjfx.io/javadoc/25/javafx.controls/javafx/scene/control/TextArea.html#setScrollTop(double) [5] https://openjfx.io/javadoc/25/jfx.incubator.richtext/jfx/incubator/scene/control/richtext/RichTextArea.html [6] https://github.com/openjdk/jfx/tree/c6413874cc60c9ccbcd8914ba18154a96bbf7536 [7] https://github.com/openjdk/jfx/blob/c6413874cc60c9ccbcd8914ba18154a96bbf7536/modules/jfx.incubator.richtext/src/main/java/com/sun/jfx/incubator/scene/control/richtext/VFlow.java#L566 [8] https://github.com/openjdk/jfx/blob/c6413874cc60c9ccbcd8914ba18154a96bbf7536/modules/jfx.incubator.richtext/src/main/java/com/sun/jfx/incubator/scene/control/richtext/VFlow.java#L951 [9] https://github.com/openjdk/jfx/blob/c6413874cc60c9ccbcd8914ba18154a96bbf7536/modules/jfx.incubator.richtext/src/main/java/com/sun/jfx/incubator/scene/control/richtext/VFlow.java#L993 [10] https://github.com/openjdk/jfx/blob/c6413874cc60c9ccbcd8914ba18154a96bbf7536/modules/jfx.incubator.richtext/src/main/java/com/sun/jfx/incubator/scene/control/richtext/VFlow.java#L1005 [11] https://github.com/openjdk/jfx/blob/c6413874cc60c9ccbcd8914ba18154a96bbf7536/modules/jfx.incubator.richtext/src/main/java/jfx/incubator/scene/control/richtext/RichTextArea.java
