Class TextField
java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
com.pixelmonmod.pixelmon.quests.client.editor.ui.TextField
- 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 TextField
extends net.minecraft.client.gui.components.AbstractWidget
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.client.gui.narration.NarratableEntry
net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority
-
Field Summary
Modifier and TypeFieldDescriptionfinal net.minecraft.client.gui.Font
int
int
The width of this text field.int
int
Fields inherited from class net.minecraft.client.gui.components.AbstractWidget
active, alpha, focused, hoverOrFocusedStartTime, isHovered, message, MIN_SCROLL_PERIOD, packedFGColor, PERIOD_PER_SCROLLED_PIXEL, tabOrderGroup, tooltip, tooltipMsDelay, UNSET_FG_COLOR, wasHoveredOrFocused, x, y
Fields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS
-
Constructor Summary
ConstructorDescriptionTextField
(net.minecraft.client.gui.Font fontRenderer, int xPos, int yPos, int width, int height, int backgroundColour, int borderColour) -
Method Summary
Modifier and TypeMethodDescriptionboolean
charTyped
(char p_146201_1_, int p_146201_2_) Call this method from your GuiScreen to process the keys into the textboxvoid
deleteFromCursor
(int p_146175_1_) delete the selected text, otherwsie deletes characters from either side of the cursor.void
deleteWords
(int p_146177_1_) Deletes the specified number of words starting at the cursor position.int
returns the current position of the cursorboolean
get enable drawing background and outlineint
returns the maximum number of character that can be contained in this textboxint
getNthWordFromCursor
(int p_146187_1_) see @getNthNextWordFromPos() params: N, positionint
getNthWordFromPos
(int p_146183_1_, int p_146183_2_) gets the position of the nth word.returns the text between the cursor and selectionEndint
the side of the selection that is not the cursor, may be the same as the cursorgetText()
Returns the contents of the textboxboolean
returns true if this textbox is visibleint
getWidth()
returns the width of the textbox depending on if background drawing is enabledint
getWordPosition
(int p_146197_1_, int p_146197_2_, boolean p_146197_3_) boolean
Getter for the focused fieldboolean
mouseClicked
(double p_146192_1_, double p_146192_2_, int p_146192_3_) Args: x, y, buttonClickedvoid
moveCursorBy
(int p_146182_1_) Moves the text cursor by a specified number of characters and clears the selectionvoid
renderWidget
(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) Draws the textboxvoid
setBorderColour
(int color) void
setCanLoseFocus
(boolean p_146205_1_) if true the textbox can lose focus by clicking elsewhere on the screenvoid
setCursorPosition
(int p_146190_1_) sets the position of the cursor to the provided indexvoid
sets the cursors position to after the textvoid
sets the cursors position to the beginningvoid
setDisabledTextColour
(int p_146204_1_) void
setEnableBackgroundDrawing
(boolean p_146185_1_) enable drawing background and outlinevoid
setEnabled
(boolean p_146184_1_) void
setFocused
(boolean p_146195_1_) Sets focus to this gui elementvoid
setMaxStringLength
(int p_146203_1_) void
setSelectionPos
(int p_146199_1_) Sets the position of the selection anchor (i.e.void
Sets the text of the textboxvoid
setTextColor
(int p_146193_1_) Sets the text colour for this textbox (disabled text will not use this colour)void
setVisible
(boolean p_146189_1_) Sets whether or not this textbox is visiblevoid
Increments the cursor counterprotected void
updateWidgetNarration
(net.minecraft.client.gui.narration.NarrationElementOutput p_259858_) void
replaces selected text, or inserts text at the position on the cursorMethods inherited from class net.minecraft.client.gui.components.AbstractWidget
clearFGColor, clicked, createNarrationMessage, createTooltipPositioner, defaultButtonNarrationText, getFGColor, getHeight, getMessage, getRectangle, getTabOrderGroup, getTooltip, getX, getY, isActive, isHovered, isHoveredOrFocused, isMouseOver, isValidClickButton, mouseDragged, mouseReleased, narrationPriority, nextFocusPath, onClick, onDrag, onRelease, playDownSound, 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, keyPressed, keyReleased, mouseMoved, mouseScrolled
Methods inherited from interface net.minecraft.client.gui.layouts.LayoutElement
setPosition
-
Field Details
-
font
public final net.minecraft.client.gui.Font font -
xPosition
public int xPosition -
yPosition
public int yPosition -
width
public int widthThe width of this text field. -
height
public int height
-
-
Constructor Details
-
TextField
public TextField(net.minecraft.client.gui.Font fontRenderer, int xPos, int yPos, int width, int height, int backgroundColour, int borderColour)
-
-
Method Details
-
updateCursorCounter
public void updateCursorCounter()Increments the cursor counter -
setText
Sets the text of the textbox -
getText
Returns the contents of the textbox -
getSelectedText
returns the text between the cursor and selectionEnd -
writeText
replaces selected text, or inserts text at the position on the cursor -
deleteWords
public void deleteWords(int p_146177_1_) Deletes the specified number of words starting at the cursor position. Negative numbers will delete words left of the cursor. -
deleteFromCursor
public void deleteFromCursor(int p_146175_1_) delete the selected text, otherwsie deletes characters from either side of the cursor. params: delete num -
getNthWordFromCursor
public int getNthWordFromCursor(int p_146187_1_) see @getNthNextWordFromPos() params: N, position -
getNthWordFromPos
public int getNthWordFromPos(int p_146183_1_, int p_146183_2_) gets the position of the nth word. N may be negative, then it looks backwards. params: N, position -
getWordPosition
public int getWordPosition(int p_146197_1_, int p_146197_2_, boolean p_146197_3_) -
moveCursorBy
public void moveCursorBy(int p_146182_1_) Moves the text cursor by a specified number of characters and clears the selection -
setCursorPosition
public void setCursorPosition(int p_146190_1_) sets the position of the cursor to the provided index -
setCursorPositionZero
public void setCursorPositionZero()sets the cursors position to the beginning -
setCursorPositionEnd
public void setCursorPositionEnd()sets the cursors position to after the text -
charTyped
public boolean charTyped(char p_146201_1_, int p_146201_2_) Call this method from your GuiScreen to process the keys into the textbox -
mouseClicked
public boolean mouseClicked(double p_146192_1_, double p_146192_2_, int p_146192_3_) Args: x, y, buttonClicked- Specified by:
mouseClicked
in interfacenet.minecraft.client.gui.components.events.GuiEventListener
- Overrides:
mouseClicked
in classnet.minecraft.client.gui.components.AbstractWidget
- Returns:
-
renderWidget
public void renderWidget(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) Draws the textbox- Specified by:
renderWidget
in classnet.minecraft.client.gui.components.AbstractWidget
-
setMaxStringLength
public void setMaxStringLength(int p_146203_1_) -
getMaxStringLength
public int getMaxStringLength()returns the maximum number of character that can be contained in this textbox -
getCursorPosition
public int getCursorPosition()returns the current position of the cursor -
getEnableBackgroundDrawing
public boolean getEnableBackgroundDrawing()get enable drawing background and outline -
setEnableBackgroundDrawing
public void setEnableBackgroundDrawing(boolean p_146185_1_) enable drawing background and outline -
setTextColor
public void setTextColor(int p_146193_1_) Sets the text colour for this textbox (disabled text will not use this colour) -
setBorderColour
public void setBorderColour(int color) -
setDisabledTextColour
public void setDisabledTextColour(int p_146204_1_) -
setFocused
public void setFocused(boolean p_146195_1_) Sets focus to this gui element- Specified by:
setFocused
in interfacenet.minecraft.client.gui.components.events.GuiEventListener
- Overrides:
setFocused
in classnet.minecraft.client.gui.components.AbstractWidget
-
updateWidgetNarration
protected void updateWidgetNarration(net.minecraft.client.gui.narration.NarrationElementOutput p_259858_) - Specified by:
updateWidgetNarration
in classnet.minecraft.client.gui.components.AbstractWidget
-
isFocused
public boolean isFocused()Getter for the focused field- Specified by:
isFocused
in interfacenet.minecraft.client.gui.components.events.GuiEventListener
- Overrides:
isFocused
in classnet.minecraft.client.gui.components.AbstractWidget
-
setEnabled
public void setEnabled(boolean p_146184_1_) -
getSelectionEnd
public int getSelectionEnd()the side of the selection that is not the cursor, may be the same as the cursor -
getWidth
public int getWidth()returns the width of the textbox depending on if background drawing is enabled- Specified by:
getWidth
in interfacenet.minecraft.client.gui.layouts.LayoutElement
- Overrides:
getWidth
in classnet.minecraft.client.gui.components.AbstractWidget
-
setSelectionPos
public void setSelectionPos(int p_146199_1_) Sets the position of the selection anchor (i.e. position the selection was started at) -
setCanLoseFocus
public void setCanLoseFocus(boolean p_146205_1_) if true the textbox can lose focus by clicking elsewhere on the screen -
getVisible
public boolean getVisible()returns true if this textbox is visible -
setVisible
public void setVisible(boolean p_146189_1_) Sets whether or not this textbox is visible
-