Class Styles.TextFieldStyle

java.lang.Object
com.github.tommyettinger.textra.Styles.TextFieldStyle
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
Enclosing class:
Styles

public static class Styles.TextFieldStyle extends Object implements com.badlogic.gdx.utils.Disposable
The style for a text field, see TextraField. This is Disposable because it always copies any Font it is given (unless font is directly assigned, which should be avoided). To avoid the copy becoming inaccessible while still holding native resources, you should dispose this style when you are completely finished using it (and don't intend to use it again). You can also just dispose the font, which does the same thing as calling dispose() on the style.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    com.badlogic.gdx.scenes.scene2d.utils.Drawable
     
    com.badlogic.gdx.scenes.scene2d.utils.Drawable
     
    com.badlogic.gdx.scenes.scene2d.utils.Drawable
     
    com.badlogic.gdx.graphics.Color
     
    com.badlogic.gdx.scenes.scene2d.utils.Drawable
     
    com.badlogic.gdx.graphics.Color
     
     
    com.badlogic.gdx.graphics.Color
     
    com.badlogic.gdx.graphics.Color
     
    com.badlogic.gdx.scenes.scene2d.utils.Drawable
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    TextFieldStyle(com.badlogic.gdx.graphics.g2d.BitmapFont font, com.badlogic.gdx.graphics.Color fontColor, com.badlogic.gdx.scenes.scene2d.utils.Drawable cursor, com.badlogic.gdx.scenes.scene2d.utils.Drawable selection, com.badlogic.gdx.scenes.scene2d.utils.Drawable background)
    Deprecated.
    Create a Font from your BitmapFont once and pass that to constructors instead.
    TextFieldStyle(com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldStyle style)
    This constructor copies the BitmapFont in the given style, but so do all constructors for this class.
    TextFieldStyle(Font font, com.badlogic.gdx.graphics.Color fontColor, com.badlogic.gdx.scenes.scene2d.utils.Drawable cursor, com.badlogic.gdx.scenes.scene2d.utils.Drawable selection, com.badlogic.gdx.scenes.scene2d.utils.Drawable background)
    This copies the given TextFieldStyle's Font so it can have Font.omitCurlyBraces and Font.enableSquareBrackets both set to false, which other usage rarely wants to do.
    This copies the given TextFieldStyle's Font so it can have Font.omitCurlyBraces and Font.enableSquareBrackets both set to false, which other usage rarely wants to do.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Releases all resources of this object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • font

      public Font font
    • fontColor

      public com.badlogic.gdx.graphics.Color fontColor
    • focusedFontColor

      @Null public com.badlogic.gdx.graphics.Color focusedFontColor
    • disabledFontColor

      @Null public com.badlogic.gdx.graphics.Color disabledFontColor
    • background

      @Null public com.badlogic.gdx.scenes.scene2d.utils.Drawable background
    • focusedBackground

      @Null public com.badlogic.gdx.scenes.scene2d.utils.Drawable focusedBackground
    • disabledBackground

      @Null public com.badlogic.gdx.scenes.scene2d.utils.Drawable disabledBackground
    • cursor

      @Null public com.badlogic.gdx.scenes.scene2d.utils.Drawable cursor
    • selection

      @Null public com.badlogic.gdx.scenes.scene2d.utils.Drawable selection
    • messageFontColor

      @Null public com.badlogic.gdx.graphics.Color messageFontColor
  • Constructor Details

    • TextFieldStyle

      public TextFieldStyle()
    • TextFieldStyle

      public TextFieldStyle(Font font, com.badlogic.gdx.graphics.Color fontColor, @Null com.badlogic.gdx.scenes.scene2d.utils.Drawable cursor, @Null com.badlogic.gdx.scenes.scene2d.utils.Drawable selection, @Null com.badlogic.gdx.scenes.scene2d.utils.Drawable background)
      This copies the given TextFieldStyle's Font so it can have Font.omitCurlyBraces and Font.enableSquareBrackets both set to false, which other usage rarely wants to do.
      Parameters:
      font - the non-null Font to use for text; will be copied
      fontColor - the color to tint the given Font by default
      cursor - you probably want to use the predefined skin.getDrawable("cursor") for this
      selection - may be null, but is usually a solid block that will be stretched behind a selected area
      background - may be null; otherwise, drawn behind the widget as its background
    • TextFieldStyle

      @Deprecated public TextFieldStyle(com.badlogic.gdx.graphics.g2d.BitmapFont font, com.badlogic.gdx.graphics.Color fontColor, @Null com.badlogic.gdx.scenes.scene2d.utils.Drawable cursor, @Null com.badlogic.gdx.scenes.scene2d.utils.Drawable selection, @Null com.badlogic.gdx.scenes.scene2d.utils.Drawable background)
      Deprecated.
      Create a Font from your BitmapFont once and pass that to constructors instead.
      You should almost always avoid calling this constructor directly, because it allocates a new Font object every time (copying information from the given BitmapFont), and it isn't easy to dispose the created Font.
      Parameters:
      font - a BitmapFont that will be copied into a new Font
      fontColor - the color to tint the given BitmapFont
      cursor - you probably want to use the predefined skin.getDrawable("cursor") for this
      selection - may be null, but is usually a solid block that will be stretched behind a selected area
      background - may be null; otherwise, drawn behind the widget as its background
    • TextFieldStyle

      public TextFieldStyle(Styles.TextFieldStyle style)
      This copies the given TextFieldStyle's Font so it can have Font.omitCurlyBraces and Font.enableSquareBrackets both set to false, which other usage rarely wants to do.
      Parameters:
      style - an existing instance of this type, to copy
    • TextFieldStyle

      public TextFieldStyle(com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldStyle style)
      This constructor copies the BitmapFont in the given style, but so do all constructors for this class. Using a Font with Styles is normally encouraged instead of using a BitmapFont, though.
      Parameters:
      style - a Label.LabelStyle that will have its data and BitmapFont copied into this and its Font
  • Method Details

    • dispose

      public void dispose()
      Releases all resources of this object. Calls Font.dispose() on font, but does nothing else. This style is Disposable because it creates a copy of any Font it is given. If you are using the same TextFieldStyle for multiple TextraFields, then you should only dispose the TextFieldStyle when you are no longer using the style for any current or future TextraFields.
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable