Class TabCompleteTextField

java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
net.minecraft.client.gui.components.EditBox
com.pixelmonmod.pixelmon.client.gui.widgets.TabCompleteTextField
All Implemented Interfaces:
net.minecraft.client.gui.components.events.GuiEventListener, net.minecraft.client.gui.components.Renderable, net.minecraft.client.gui.components.TabOrderedElement, net.minecraft.client.gui.layouts.LayoutElement, net.minecraft.client.gui.narration.NarratableEntry, net.minecraft.client.gui.narration.NarrationSupplier

public class TabCompleteTextField extends net.minecraft.client.gui.components.EditBox
Created by Jay113355 on 3/31/2020.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface net.minecraft.client.gui.narration.NarratableEntry

    net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected List<String>
     
    int
     
    protected int
     
    protected boolean
     

    Fields inherited from class net.minecraft.client.gui.components.EditBox

    BACKWARDS, bordered, canLoseFocus, CURSOR_APPEND_CHARACTER, CURSOR_BLINK_INTERVAL_MS, CURSOR_INSERT_COLOR, CURSOR_INSERT_WIDTH, cursorPos, DEFAULT_TEXT_COLOR, displayPos, filter, focusedTime, font, formatter, FORWARDS, highlightPos, hint, isEditable, maxLength, responder, SPRITES, suggestion, textColor, textColorUneditable, value

    Fields inherited from class net.minecraft.client.gui.components.AbstractWidget

    active, alpha, focused, height, hoverOrFocusedStartTime, isHovered, message, MIN_SCROLL_PERIOD, packedFGColor, PERIOD_PER_SCROLLED_PIXEL, tabOrderGroup, tooltip, tooltipMsDelay, UNSET_FG_COLOR, visible, wasHoveredOrFocused, width, x, y

    Fields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener

    DOUBLE_CLICK_THRESHOLD_MS
  • Constructor Summary

    Constructors
    Constructor
    Description
    TabCompleteTextField(int componentId, net.minecraft.client.gui.Font fontrendererObj, int x, int y, int par5Width, int par6Height)
     
    TabCompleteTextField(int componentId, net.minecraft.client.gui.Font fontrendererObj, int x, int y, int par5Width, int par6Height, Pokemon pokemon)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    charTyped(char typedChar, int keyCode)
    Call this method from your GuiScreen to process the keys into the textbox
    protected void
     
    void
    Adds the completions generated to a separate list that will only hold an amount set by TabCompleteTranslateableTextField.setDropDownOptionAmount(int).
    void
    fillDropDownWithCompletions(net.minecraft.client.gui.GuiGraphics graphics)
    Holds the values that keep track of where the y position of the next auto-completion text should render.
    int
    getIndexOfDropDownOptionMouseIsOver(double mouseX, double mouseY)
     
    boolean
     
    boolean
    keyPressed(int key, int scanCode, int modifiers)
     
    boolean
    mouseReleased(double mouseX, double mouseY, int button)
     
    int
    renderCompletionAsString(net.minecraft.client.gui.GuiGraphics graphics, int optionIndex, int dropDownOptionTextStartX, int dropDownOptionTextStartY)
    Render one of the completions without any fancy formatting or extra info.
    void
    renderEditBoxAsDropDown(net.minecraft.client.gui.GuiGraphics graphics)
    Renders an Edit Box larger to fit extra info.
    void
    renderWidget(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks)
     
    void
    renderWidgetWithDropDown(net.minecraft.client.gui.GuiGraphics graphics)
    Literally a duplicate of EditBox.renderWidget(GuiGraphics, int, int, float) except that the typed text is not centered and instead kept at the top of the edit box.
     
    void
    setFocused(boolean focus)
     
    void
    setShowDropDown(boolean show)
    Turns on or off the rendering of the edit box as a large dropdown showing completions for the typed text
    updatePosition(int x, int y)
     

    Methods inherited from class net.minecraft.client.gui.components.EditBox

    canConsumeInput, createNarrationMessage, deleteChars, deleteWords, getCursorPosition, getHighlighted, getInnerWidth, getMaxLength, getScreenX, getValue, getWordPosition, insertText, isBordered, isMouseOver, isVisible, moveCursor, moveCursorTo, moveCursorToEnd, moveCursorToStart, nextFocusPath, onClick, playDownSound, renderHighlight, setBordered, setCanLoseFocus, setCursorPosition, setEditable, setFilter, setFormatter, setHighlightPos, setHint, setMaxLength, setResponder, setSuggestion, setTextColor, setTextColorUneditable, setValue, setVisible, updateWidgetNarration

    Methods inherited from class net.minecraft.client.gui.components.AbstractWidget

    clearFGColor, clicked, createTooltipPositioner, defaultButtonNarrationText, getFGColor, getHeight, getMessage, getRectangle, getTabOrderGroup, getTooltip, getWidth, getX, getY, isActive, isFocused, isHovered, isHoveredOrFocused, isValidClickButton, mouseClicked, mouseDragged, narrationPriority, onDrag, onRelease, render, renderScrollingString, renderScrollingString, renderScrollingString, setAlpha, setFGColor, setHeight, setMessage, setTabOrderGroup, setTooltip, setTooltipDelay, setWidth, setX, setY, updateNarration, visitWidgets, wrapDefaultNarrationMessage

    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.components.events.GuiEventListener

    getCurrentFocusPath, keyReleased, mouseMoved, mouseScrolled

    Methods inherited from interface net.minecraft.client.gui.layouts.LayoutElement

    setPosition

    Methods inherited from interface net.minecraft.client.gui.components.Renderable

    render
  • Field Details

    • cache

      protected List<String> cache
    • isCompleting

      protected boolean isCompleting
    • index

      protected int index
    • id

      public int id
  • Constructor Details

    • TabCompleteTextField

      public TabCompleteTextField(int componentId, net.minecraft.client.gui.Font fontrendererObj, int x, int y, int par5Width, int par6Height)
    • TabCompleteTextField

      public TabCompleteTextField(int componentId, net.minecraft.client.gui.Font fontrendererObj, int x, int y, int par5Width, int par6Height, Pokemon pokemon)
  • Method Details

    • setCompletions

      public TabCompleteTextField setCompletions(Collection<String> completions)
    • keyPressed

      public boolean keyPressed(int key, int scanCode, int modifiers)
      Specified by:
      keyPressed in interface net.minecraft.client.gui.components.events.GuiEventListener
      Overrides:
      keyPressed in class net.minecraft.client.gui.components.EditBox
    • mouseReleased

      public boolean mouseReleased(double mouseX, double mouseY, int button)
      Specified by:
      mouseReleased in interface net.minecraft.client.gui.components.events.GuiEventListener
      Overrides:
      mouseReleased in class net.minecraft.client.gui.components.AbstractWidget
    • getIndexOfDropDownOptionMouseIsOver

      public int getIndexOfDropDownOptionMouseIsOver(double mouseX, double mouseY)
    • charTyped

      public boolean charTyped(char typedChar, int keyCode)
      Call this method from your GuiScreen to process the keys into the textbox
      Specified by:
      charTyped in interface net.minecraft.client.gui.components.events.GuiEventListener
      Overrides:
      charTyped in class net.minecraft.client.gui.components.EditBox
      Parameters:
      typedChar -
      keyCode -
    • createCompletionsFor

      protected void createCompletionsFor(String leftOfCursor)
    • updatePosition

      protected TabCompleteTextField updatePosition(int x, int y)
    • getShowDropDown

      public boolean getShowDropDown()
    • setShowDropDown

      public void setShowDropDown(boolean show)
      Turns on or off the rendering of the edit box as a large dropdown showing completions for the typed text
      Parameters:
      show - true or false
    • setFocused

      public void setFocused(boolean focus)
      Specified by:
      setFocused in interface net.minecraft.client.gui.components.events.GuiEventListener
      Overrides:
      setFocused in class net.minecraft.client.gui.components.EditBox
    • renderWidget

      public void renderWidget(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks)
      Overrides:
      renderWidget in class net.minecraft.client.gui.components.EditBox
    • renderWidgetWithDropDown

      public void renderWidgetWithDropDown(net.minecraft.client.gui.GuiGraphics graphics)
      Literally a duplicate of EditBox.renderWidget(GuiGraphics, int, int, float) except that the typed text is not centered and instead kept at the top of the edit box.
      Parameters:
      graphics - The PoseStack matrix
    • renderEditBoxAsDropDown

      public void renderEditBoxAsDropDown(net.minecraft.client.gui.GuiGraphics graphics)
      Renders an Edit Box larger to fit extra info.

      Gets the sprite for the Edit Box and then increases its size vertically so that it can fit the completions that this widget is generating for what the user is typing.

      Parameters:
      graphics - The PoseStack matrix
    • createCompletionsForDropDown

      public void createCompletionsForDropDown(String leftOfCursor)
      Adds the completions generated to a separate list that will only hold an amount set by TabCompleteTranslateableTextField.setDropDownOptionAmount(int).
      Parameters:
      leftOfCursor - The text in the widget
    • fillDropDownWithCompletions

      public void fillDropDownWithCompletions(net.minecraft.client.gui.GuiGraphics graphics)
      Holds the values that keep track of where the y position of the next auto-completion text should render. Calls a render function for the allowed amount of options to display the text for each auto-complete option.
      Parameters:
      graphics - The PoseStack matrix
    • renderCompletionAsString

      public int renderCompletionAsString(net.minecraft.client.gui.GuiGraphics graphics, int optionIndex, int dropDownOptionTextStartX, int dropDownOptionTextStartY)
      Render one of the completions without any fancy formatting or extra info.
      Parameters:
      graphics - The PoseStack matrix
      optionIndex - which number completion this is, meaning we've rendered optionIndex-1 completions so far
      dropDownOptionTextStartX - The starting x position of the text
      dropDownOptionTextStartY - The starting y position of the text
      Returns:
      the starting y position for the next completion text to render in the drop-down