@NullMarked public class TextInputGuiElement extends BaseInputGuiElement<TextInputStyles,TextInputGuiElement>
TextInputGuiElement is a BaseInputGuiElement that allows users to interact via typing text into the field.
  • Constructor Details

    • TextInputGuiElement

      public TextInputGuiElement()
      Creates an instance of TextInputGuiElement registering default event listeners for typing characters into the field.
  • Method Details

    • renderContent

      public void renderContent(Renderer renderer)
      Description copied from class: GuiElement
      Method to render the main content of the gui element (not borders, backgrounds, etc.).
      Specified by:
      renderContent in class GuiElement<TextInputStyles,TextInputGuiElement>
      Parameters:
      renderer - the Renderer instance
    • calculateContentDimensions

      public GuiElementDimensions calculateContentDimensions()
      Description copied from class: GuiElement
      Calculates content dimensions for this element. If its dimensions are derived from only its children then it should return null.
      Specified by:
      calculateContentDimensions in class GuiElement<TextInputStyles,TextInputGuiElement>
      Returns:
      the dimensions of the content of this element or null if only children dimensions matter
    • appendChildren

      public TextInputGuiElement appendChildren(GuiElement<?,?>... children)
      TextInputGuiElement does not render children so this method will do nothing.
      Overrides:
      appendChildren in class GuiElement<TextInputStyles,TextInputGuiElement>
      Parameters:
      children - the child elements to add
      Returns:
      this
    • removeChild

      public TextInputGuiElement removeChild(GuiElement<?,?> child)
      TextInputGuiElement does not render children so this method will do nothing.
      Overrides:
      removeChild in class GuiElement<TextInputStyles,TextInputGuiElement>
      Parameters:
      child - the child element that will not be removed
      Returns:
      this
    • getChildren

      public List<GuiElement<?,?>> getChildren()
      TextInputGuiElement does not render children so this method will return an empty List.
      Overrides:
      getChildren in class GuiElement<TextInputStyles,TextInputGuiElement>
      Returns:
      empty List
    • getPlaceholder

      public String getPlaceholder()
      Returns:
      the placeholder when no user value is entered
    • setPlaceholder

      public TextInputGuiElement setPlaceholder(String placeholder)
      Sets the placeholder text for when no user value is entered.
      Parameters:
      placeholder - the new placeholder text
      Returns:
      this
    • getMaxLength

      public @Nullable Integer getMaxLength()
      Returns:
      the maximum number of characters allowed for the input
    • setMaxLength

      public TextInputGuiElement setMaxLength(@Nullable Integer maxLength)
      Sets the maximum number of characters allowed for the input. If the new length is smaller than the entered value it will be truncated down to the new max length.
      Parameters:
      maxLength - the new max length
      Returns:
      this
    • getValue

      public String getValue()
      Returns:
      the user entered value in the input
    • setValue

      public TextInputGuiElement setValue(String value)
      Programmatically sets the user entered value of the input.
      Parameters:
      value - the new value of the input
      Returns:
      this