Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8233810

Add tabSize property to Text and TextFlow

    Details

    • Type: CSR
    • Status: Draft
    • Priority: P4
    • Resolution: Unresolved
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      Some applications may have extended Text or TextFlow to implement getTabSize, setTabSize, and/or tabSizeProperty in incompatible ways.

      Description

      Summary

      Add APIs to configure the tab size of Text and TextFlow nodes.

      Problem

      The current tab size is hard coded to 8 spaces. Text editors often allow for a configurable tab size. Something like that is very difficult to implement well in JavaFX with the current implementation of Text and TextFlow. Work-arounds such as inserting spaces instead of tabs results in a poor user experience when navigating the text.

      Solution

      Introduce a tabSize property and a corresponding -fx-tab-size CSS property to Text and TextFlow nodes, along with APIs to configure and query this property. This integer property will set the tab size as a number of spaces in the current font.

      Specification

      Text.java

      /**
       * The size of a tab stop in spaces.
       * Values less than 1 are treated as 1.
       *
       * @defaultValue {@code 8}
       *
       * @since 14
       */
      public final IntegerProperty tabSizeProperty() { }
      public final void setTabSize(int spaces) { }
      public final int getTabSize() { }

      TextFlow.java

      /**
       * The size of a tab stop in spaces.
       * Values less than 1 are treated as 1. This value overrides the
       * {@code tabSize} of contained {@link javafx.scene.text.Text Text} nodes.
       *
       * @defaultValue {@code 8}
       *
       * @since 14
       */
      public final IntegerProperty tabSizeProperty() { }
      public final void setTabSize(int spaces) { }
      public final int getTabSize() { }

      csssref.html

      Text
      
      Style class: empty by default
      
        CSS Property    Values    Default
      -fx-tab-size    <integer>      8

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                swpalmer Scott Palmer
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated: