Class MultiLineInput.Builder

Enclosing class:
MultiLineInput

public static final class MultiLineInput.Builder extends Entry.Builder<MultiLineInput.Builder>
Builds a MultiLineInput; from MultiLineInput.builder(String). Also has the options every entry has (Entry.Builder).
  • Method Details

    • label

      public MultiLineInput.Builder label(Supplier<Text> label)
      The text above the box, re-read on every refresh. Required.
      Parameters:
      label - read on refresh
      Returns:
      this builder
    • label

      public MultiLineInput.Builder label(Text label)
      A fixed label; see label(Supplier).
      Parameters:
      label - the label
      Returns:
      this builder
    • initial

      public MultiLineInput.Builder initial(String initial)
      The text the box starts with; empty by default. Line breaks may be "\n", "\r\n" or "\r"; cut to maxLength. Not passed to onChange.
      Parameters:
      initial - the starting text
      Returns:
      this builder
    • maxLength

      public MultiLineInput.Builder maxLength(int maxLength)
      The most characters the box accepts, line breaks included; 1024 by default. Must be positive.
      Parameters:
      maxLength - the limit
      Returns:
      this builder
    • lines

      public MultiLineInput.Builder lines(int lines)
      How many lines the box shows at once, from 2 to 12; 4 by default. Longer text scrolls.
      Parameters:
      lines - the box's height in lines
      Returns:
      this builder
    • validator

      public MultiLineInput.Builder validator(Function<String,Text> validator)
      Checks the text: returns an error text for invalid input (shown below the box), null for valid input. Runs often, on the main thread. By default every text is valid.
      Parameters:
      validator - maps the text to an error, or null
      Returns:
      this builder
    • onChange

      public MultiLineInput.Builder onChange(Consumer<String> onChange)
      Receives the text after each edit that leaves it valid, on the main thread. Optional.
      Parameters:
      onChange - receives valid text
      Returns:
      this builder
    • build

      public MultiLineInput build()
      Builds the text box.
      Returns:
      the text box
      Throws:
      IllegalStateException - if label is missing, maxLength is not positive or lines is outside 2 – 12