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,net.neoforged.neoforge.client.extensions.IAbstractWidgetExtension
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
FieldsModifier and TypeFieldDescriptionintprotected intprotected booleanFields 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, textShadow, valueFields inherited from class net.minecraft.client.gui.components.AbstractWidget
active, alpha, height, isHovered, packedFGColor, UNSET_FG_COLOR, visible, width, x, yFields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS -
Constructor Summary
ConstructorsConstructorDescriptionTabCompleteTextField(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 TypeMethodDescriptionbooleancharTyped(char typedChar, int keyCode) Call this method from your GuiScreen to process the keys into the textboxprotected voidcreateCompletionsFor(String leftOfCursor) voidcreateCompletionsForDropDown(String leftOfCursor) Adds the completions generated to a separate list that will only hold an amount set byTabCompleteTranslateableTextField.setDropDownOptionAmount(int).voidfillDropDownWithCompletions(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.intgetIndexOfDropDownOptionMouseIsOver(double mouseX, double mouseY) booleanbooleankeyPressed(int key, int scanCode, int modifiers) booleanmouseReleased(double mouseX, double mouseY, int button) intrenderCompletionAsString(net.minecraft.client.gui.GuiGraphics graphics, int optionIndex, int dropDownOptionTextStartX, int dropDownOptionTextStartY) Render one of the completions without any fancy formatting or extra info.voidrenderEditBoxAsDropDown(net.minecraft.client.gui.GuiGraphics graphics) Renders an Edit Box larger to fit extra info.voidrenderWidget(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) voidrenderWidgetWithDropDown(net.minecraft.client.gui.GuiGraphics graphics) Literally a duplicate ofEditBox.renderWidget(GuiGraphics, int, int, float)except that the typed text is not centered and instead kept at the top of the edit box.setCompletions(Collection<String> completions) voidsetFocused(boolean focus) voidsetShowDropDown(boolean show) Turns on or off the rendering of the edit box as a large dropdown showing completions for the typed textprotected TabCompleteTextFieldupdatePosition(int x, int y) Methods inherited from class net.minecraft.client.gui.components.EditBox
canConsumeInput, createNarrationMessage, deleteChars, deleteCharsToPos, deleteWords, getCursorPosition, getHighlighted, getInnerWidth, getMaxLength, getScreenX, getTextShadow, getValue, getWordPosition, insertText, isBordered, isVisible, moveCursor, moveCursorTo, moveCursorToEnd, moveCursorToStart, onClick, playDownSound, renderHighlight, setBordered, setCanLoseFocus, setCursorPosition, setEditable, setFilter, setFormatter, setHighlightPos, setHint, setMaxLength, setResponder, setSuggestion, setTextColor, setTextColorUneditable, setTextShadow, setValue, setVisible, updateWidgetNarrationMethods inherited from class net.minecraft.client.gui.components.AbstractWidget
clearFGColor, clicked, defaultButtonNarrationText, getBottom, getFGColor, getHeight, getMessage, getRectangle, getRight, getTabOrderGroup, getTooltip, getWidth, getX, getY, isActive, isFocused, isHovered, isHoveredOrFocused, isMouseOver, isValidClickButton, mouseClicked, mouseDragged, narrationPriority, nextFocusPath, onDrag, onRelease, render, renderScrollingString, renderScrollingString, renderScrollingString, setAlpha, setFGColor, setHeight, setMessage, setRectangle, setSize, setTabOrderGroup, setTooltip, setTooltipDelay, setWidth, setX, setY, updateNarration, visitWidgets, wrapDefaultNarrationMessageMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
getCurrentFocusPath, keyReleased, mouseMoved, mouseScrolledMethods inherited from interface net.neoforged.neoforge.client.extensions.IAbstractWidgetExtension
onClickMethods inherited from interface net.minecraft.client.gui.layouts.LayoutElement
setPositionMethods inherited from interface net.minecraft.client.gui.components.Renderable
render
-
Field Details
-
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
-
keyPressed
public boolean keyPressed(int key, int scanCode, int modifiers) - Specified by:
keyPressedin interfacenet.minecraft.client.gui.components.events.GuiEventListener- Overrides:
keyPressedin classnet.minecraft.client.gui.components.EditBox
-
mouseReleased
public boolean mouseReleased(double mouseX, double mouseY, int button) - Specified by:
mouseReleasedin interfacenet.minecraft.client.gui.components.events.GuiEventListener- Overrides:
mouseReleasedin classnet.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:
charTypedin interfacenet.minecraft.client.gui.components.events.GuiEventListener- Overrides:
charTypedin classnet.minecraft.client.gui.components.EditBox- Parameters:
typedChar-keyCode-
-
createCompletionsFor
-
updatePosition
-
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:
setFocusedin interfacenet.minecraft.client.gui.components.events.GuiEventListener- Overrides:
setFocusedin classnet.minecraft.client.gui.components.EditBox
-
renderWidget
public void renderWidget(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) - Overrides:
renderWidgetin classnet.minecraft.client.gui.components.EditBox
-
renderWidgetWithDropDown
public void renderWidgetWithDropDown(net.minecraft.client.gui.GuiGraphics graphics) Literally a duplicate ofEditBox.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
Adds the completions generated to a separate list that will only hold an amount set byTabCompleteTranslateableTextField.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 matrixoptionIndex- which number completion this is, meaning we've rendered optionIndex-1 completions so fardropDownOptionTextStartX- The starting x position of the textdropDownOptionTextStartY- The starting y position of the text- Returns:
- the starting y position for the next completion text to render in the drop-down
-