Class TextInput


  • public final class TextInput
    extends Section
    A single-line editable text field with caret movement and horizontal scrolling. Enter fires onSubmit; edits fire onChange. Do not pair a printable quit key with a focused TextInput (it would be typed); use a non-printable quit such as Ctrl-C or Escape.
    • Constructor Summary

      Constructors 
      Constructor Description
      TextInput()
      Creates an empty field.
      TextInput​(java.lang.String initial)
      Creates a field initialized with the given text.
    • Constructor Detail

      • TextInput

        public TextInput()
        Creates an empty field.
      • TextInput

        public TextInput​(java.lang.String initial)
        Creates a field initialized with the given text.
        Parameters:
        initial - the initial text
    • Method Detail

      • setText

        public TextInput setText​(java.lang.String value)
        Sets the field text, moving the caret to the end. A null value clears the field.
        Parameters:
        value - the new text
        Returns:
        this TextInput for chaining
      • text

        public java.lang.String text()
        Returns:
        the current text
      • placeholder

        public TextInput placeholder​(java.lang.String placeholder)
        Sets the placeholder shown when the field is empty and unfocused. A null value is treated as empty.
        Parameters:
        placeholder - the placeholder text
        Returns:
        this TextInput for chaining
      • style

        public TextInput style​(Style style)
        Sets the style used to draw the text.
        Parameters:
        style - the text style
        Returns:
        this TextInput for chaining
      • placeholderStyle

        public TextInput placeholderStyle​(Style style)
        Sets the style used to draw the placeholder.
        Parameters:
        style - the placeholder style
        Returns:
        this TextInput for chaining
      • onSubmit

        public TextInput onSubmit​(java.util.function.Consumer<java.lang.String> handler)
        Sets the handler called with the current text when Enter is pressed.
        Parameters:
        handler - the submit handler
        Returns:
        this TextInput for chaining
      • onChange

        public TextInput onChange​(java.util.function.Consumer<java.lang.String> handler)
        Sets the handler called with the current text after every edit.
        Parameters:
        handler - the change handler
        Returns:
        this TextInput for chaining