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

Add tabSize property to Text and TextFlow

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • jfx14
    • javafx
    • None
    • source, binary
    • minimal
    • Some applications may have extended Text or TextFlow to implement getTabSize, setTabSize, and/or tabSizeProperty in incompatible ways.
    • Java API
    • JDK

      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 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 Text} nodes.
       *
       * @defaultValue 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

            swpalmer Scott Palmer
            webbuggrp Webbug Group
            Kevin Rushforth
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: