Class TextInputScreen<T>

java.lang.Object
net.minecraft.client.gui.DrawableHelper
net.minecraft.client.gui.AbstractParentElement
net.minecraft.client.gui.screen.Screen
net.uku3lig.ukulib.config.screen.CloseableScreen
net.uku3lig.ukulib.config.screen.TextInputScreen<T>
Type Parameters:
T - The type of the value.
All Implemented Interfaces:
net.minecraft.client.gui.Drawable, net.minecraft.client.gui.Element, net.minecraft.client.gui.ParentElement
Direct Known Subclasses:
ColorSelectScreen, StringInputScreen

public abstract class TextInputScreen<T> extends CloseableScreen
A screen used to input a value. Instances of this class should NOT be reused.
  • Nested Class Summary

    Nested classes/interfaces inherited from class net.minecraft.client.gui.screen.Screen

    net.minecraft.client.gui.screen.Screen.SelectedElementNarrationData
  • Field Summary

    Fields inherited from class net.uku3lig.ukulib.config.screen.CloseableScreen

    parent

    Fields inherited from class net.minecraft.client.gui.screen.Screen

    client, height, itemRenderer, passEvents, textRenderer, title, width

    Fields inherited from class net.minecraft.client.gui.DrawableHelper

    GUI_ICONS_TEXTURE, OPTIONS_BACKGROUND_TEXTURE, STATS_ICON_TEXTURE

    Fields inherited from interface net.minecraft.client.gui.Element

    MAX_DOUBLE_CLICK_INTERVAL
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    TextInputScreen(net.minecraft.client.gui.screen.Screen parent, net.minecraft.text.Text title, net.minecraft.text.Text label, Consumer<T> callback, T last, ConfigManager<?> manager)
    Creates an input screen.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    protected abstract Optional<T>
    convert(String value)
    Converts the contents of the text field to the type needed.
    protected String
    format(T value)
    Formats the raw value to a String.
    protected net.minecraft.client.gui.widget.TextFieldWidget
    The text field widget.
    protected void
     
    protected void
    Called when the text field value is changed
    final void
     
    void
    render(net.minecraft.client.util.math.MatrixStack matrices, int mouseX, int mouseY, float delta)
     

    Methods inherited from class net.minecraft.client.gui.screen.Screen

    addDrawable, addDrawableChild, addElementNarrations, addScreenNarrations, addSelectableChild, applyKeyPressNarratorDelay, applyMouseMoveNarratorDelay, applyMousePressScrollNarratorDelay, applyNarratorModeChangeDelay, children, clearChildren, filesDragged, findSelectedElementData, getNarratedTitle, getTitle, getTooltipFromItem, handleTextClick, hasAltDown, hasControlDown, hasShiftDown, hide, init, insertText, isCopy, isCut, isMouseOver, isPaste, isSelectAll, isValidCharacterForName, keyPressed, narrateScreenIfNarrationEnabled, remove, renderBackground, renderBackground, renderBackgroundTexture, renderOrderedTooltip, renderTextHoverEffect, renderTooltip, renderTooltip, renderTooltip, renderTooltip, resize, sendMessage, sendMessage, shouldCloseOnEsc, shouldPause, tick, updateNarrator, wrapScreenError

    Methods inherited from class net.minecraft.client.gui.AbstractParentElement

    getFocused, isDragging, setDragging, setFocused

    Methods inherited from class net.minecraft.client.gui.DrawableHelper

    drawCenteredText, drawCenteredText, drawCenteredTextWithShadow, drawHorizontalLine, drawSprite, drawStringWithShadow, drawTexture, drawTexture, drawTexture, drawTexture, drawTextWithShadow, drawVerticalLine, drawWithOutline, drawWithShadow, fill, fillGradient, fillGradient, fillGradient, getZOffset, setZOffset

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.minecraft.client.gui.Element

    mouseMoved

    Methods inherited from interface net.minecraft.client.gui.ParentElement

    changeFocus, charTyped, focusOn, hoveredElement, keyReleased, mouseClicked, mouseDragged, mouseReleased, mouseScrolled, setInitialFocus
  • Constructor Details

    • TextInputScreen

      protected TextInputScreen(net.minecraft.client.gui.screen.Screen parent, net.minecraft.text.Text title, net.minecraft.text.Text label, Consumer<T> callback, T last, ConfigManager<?> manager)
      Creates an input screen.
      Parameters:
      parent - The parent screen
      title - The title of the screen
      label - The label to be shown above the text input field
      callback - The action to be performed when the value is changed
      last - The last known value
      manager - The config manager, used to save the config
  • Method Details

    • init

      protected void init()
      Overrides:
      init in class net.minecraft.client.gui.screen.Screen
    • convert

      protected abstract Optional<T> convert(String value)
      Converts the contents of the text field to the type needed.
      Parameters:
      value - The value of the text field, given by the user
      Returns:
      An empty optional is the value is incorrect, else the converted value
    • format

      protected String format(T value)
      Formats the raw value to a String. Useful when String#valueOf doesn't yield the correct result.
      Parameters:
      value - The value to format
      Returns:
      A string representation of the value
    • onTextChange

      protected void onTextChange(String value)
      Called when the text field value is changed
      Parameters:
      value - The new value
    • removed

      public final void removed()
      Overrides:
      removed in class net.minecraft.client.gui.screen.Screen
    • close

      public void close()
      Overrides:
      close in class CloseableScreen
    • render

      public void render(net.minecraft.client.util.math.MatrixStack matrices, int mouseX, int mouseY, float delta)
      Specified by:
      render in interface net.minecraft.client.gui.Drawable
      Overrides:
      render in class net.minecraft.client.gui.screen.Screen
    • getTextField

      protected net.minecraft.client.gui.widget.TextFieldWidget getTextField()
      The text field widget.
      Returns:
      The widget instance