Class TextInputComponent


public final class TextInputComponent extends GuiComponent<TextInputComponent>
Single-line editable text field component.
  • Constructor Details

    • TextInputComponent

      public TextInputComponent()
      Creates a text input with sensible default styling and size.
  • Method Details

    • value

      public TextInputComponent value(String value)
      Replaces the current value.
      Parameters:
      value - new field value
      Returns:
      this component
    • value

      public String value()
      Returns the current field value.
      Returns:
      current text value
    • placeholder

      public TextInputComponent placeholder(String placeholder)
      Sets placeholder text shown while the value is empty.
      Parameters:
      placeholder - literal placeholder text
      Returns:
      this component
    • placeholder

      public TextInputComponent placeholder(net.minecraft.network.chat.Component placeholder)
      Sets placeholder text shown while the value is empty.
      Parameters:
      placeholder - rich text placeholder
      Returns:
      this component
    • font

      public TextInputComponent font(GuiFont font)
      Sets the font used to render the input text.
      Parameters:
      font - font configuration
      Returns:
      this component
    • textStyle

      public TextInputComponent textStyle(GuiTextStyle style)
    • textScalePixels

      public TextInputComponent textScalePixels(float pixels)
      Sets the text size in design-space pixels.
      Parameters:
      pixels - text size
      Returns:
      this component
    • letterSpacing

      public TextInputComponent letterSpacing(float pixels)
    • lineHeight

      public TextInputComponent lineHeight(float multiplier)
    • shadow

      public TextInputComponent shadow(boolean shadow)
      Enables or disables the standard text shadow.
      Parameters:
      shadow - true to render the vanilla-style text shadow
      Returns:
      this component
    • maxLength

      public TextInputComponent maxLength(int maxLength)
      Sets the maximum number of characters the field may contain.
      Parameters:
      maxLength - maximum character count
      Returns:
      this component
    • textTransformer

      public TextInputComponent textTransformer(UnaryOperator<String> transformer)
      Sets a live text transformer applied to every attempted edit before validation.
      Parameters:
      transformer - text transformer
      Returns:
      this component
    • validator

      public TextInputComponent validator(Predicate<String> validator)
      Replaces the current validator used for live text edits.
      Parameters:
      validator - validator for the full candidate text
      Returns:
      this component
    • addValidator

      public TextInputComponent addValidator(Predicate<String> validator)
      Adds an additional validator used for live text edits.
      Parameters:
      validator - validator for the full candidate text
      Returns:
      this component
    • append

      public boolean append(String value)
      Appends text at the end of the field and runs the live transform/validation pipeline.
      Parameters:
      value - text to append
      Returns:
      true if the value changed
    • append

      public boolean append(char value)
      Appends a single character at the end of the field and runs the live transform/validation pipeline.
      Parameters:
      value - character to append
      Returns:
      true if the value changed
    • length

      public int length()
      Returns the current character count.
      Returns:
      current text length
    • onChange

      public TextInputComponent onChange(Consumer<String> onChange)
      Sets a callback invoked whenever the field value changes.
      Parameters:
      onChange - value-change callback
      Returns:
      this component
    • onSubmit

      public TextInputComponent onSubmit(Consumer<String> onSubmit)
      Sets a callback invoked when the user submits the field with Enter.
      Parameters:
      onSubmit - submit callback
      Returns:
      this component
    • onBlur

      public TextInputComponent onBlur(Consumer<String> onBlur)
      Sets a callback invoked when the field loses focus.
      Parameters:
      onBlur - blur callback
      Returns:
      this component
    • isFocusable

      protected boolean isFocusable()
      Overrides:
      isFocusable in class GuiComponent<TextInputComponent>
    • handlesMouseClick

      protected boolean handlesMouseClick(float mouseX, float mouseY, int button)
      Overrides:
      handlesMouseClick in class GuiComponent<TextInputComponent>
    • onMouseClicked

      protected boolean onMouseClicked(com.render.api.gui.GuiRenderContext context, float mouseX, float mouseY, int button)
      Overrides:
      onMouseClicked in class GuiComponent<TextInputComponent>
    • onMouseDragged

      protected boolean onMouseDragged(com.render.api.gui.GuiRenderContext context, float mouseX, float mouseY, int button, double dragX, double dragY)
      Overrides:
      onMouseDragged in class GuiComponent<TextInputComponent>
    • onMouseReleased

      protected boolean onMouseReleased(com.render.api.gui.GuiRenderContext context, float mouseX, float mouseY, int button)
      Overrides:
      onMouseReleased in class GuiComponent<TextInputComponent>
    • onKeyPressed

      protected boolean onKeyPressed(com.render.api.gui.GuiRenderContext context, int keyCode, int scanCode, int modifiers)
      Overrides:
      onKeyPressed in class GuiComponent<TextInputComponent>
    • onCharTyped

      protected boolean onCharTyped(com.render.api.gui.GuiRenderContext context, int codePoint, int modifiers)
      Overrides:
      onCharTyped in class GuiComponent<TextInputComponent>
    • onFocusChanged

      protected void onFocusChanged(boolean focused)
      Overrides:
      onFocusChanged in class GuiComponent<TextInputComponent>
    • tick

      protected void tick()
      Overrides:
      tick in class GuiComponent<TextInputComponent>
    • renderSelf

      protected void renderSelf(com.render.api.gui.GuiRenderContext context)
      Overrides:
      renderSelf in class GuiComponent<TextInputComponent>