Class EditBox
EditBoxWidget
provides the GUI for the edit box.- Mappings:
Namespace Name named net/minecraft/client/gui/EditBoxintermediary net/minecraft/class_7530official fjh
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final recordA substring of an edit box's text, specified using the indices of the start and the end. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate static final intprivate Runnableprivate final List<EditBox.Substring> private intprivate booleanprivate intprivate Stringprivate final TextRendererstatic final intA constant denoting that the edit box accepts unlimited amount of text.private final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete(int offset) Deletes the selected text, oroffsetcharacters of text from the cursor position if there is no selection.private EditBox.SubstringReturns the line that the cursor is located at.intReturns the line index that the cursor is located at.intReturns the cursor position.getLine(int index) Returns the line with indexindex.intReturns the number of total lines in the edit box.getLines()Returns the lines of the edit box's text.intReturns the maximum length of the edit box text in characters.Returns the substring of a word whose start position is after the cursor.private EditBox.SubstringgetOffsetLine(int offsetFromCurrent) Returns the line offset byoffsetFromCurrentfrom the cursor's line.Returns the substring of a word whose start position is before the cursor.Returns the text that is currently selected, or an empty string if there is no selection.Returns the current selection.getText()Returns the text of the edit box.private intgetWordEndIndex(int startIndex) Returns the end index of the word starting atstartIndex.booleanhandleSpecialKey(int keyCode) Handles the special keys, such as copy, cut, linebreak, and cursor movements.booleanReturns whether the edit box has a maximum length limit.booleanReturns whether the edit box has a selected text.voidmoveCursor(double x, double y) Moves the cursor to the specified position relative to the edit box.voidmoveCursor(CursorMovement movement, int amount) Moves the cursor byamountcharacters.voidmoveCursorLine(int offset) Moves the cursor byoffsetlines.private voidonChange()Called when the text changes.voidreplaceSelection(String string) Replaces the current selection withstring.private voidrewrap()Rewraps the text.voidsetChangeListener(Consumer<String> changeListener) Sets the change listener that is called every time the text changes.voidsetCursorChangeListener(Runnable cursorChangeListener) Sets the cursor change listener that is called every time the cursor position changes.voidsetMaxLength(int maxLength) Sets the maximum length of the edit box text in characters.voidsetSelecting(boolean selecting) Sets whether the edit box is currently selecting.voidSets the text of the edit box and moves the cursor to the end of the edit box.private StringReturnsvaluetruncated to fit in the current text.private StringtruncateForReplacement(String value) Returnsvaluetruncated to at mostmaxLengthcharacters.
-
Field Details
-
UNLIMITED_LENGTH
public static final int UNLIMITED_LENGTHA constant denoting that the edit box accepts unlimited amount of text. Edit box widgets with such edit boxes do not show the current text length indicator.- See Also:
- Mappings:
Namespace Name Mixin selector named UNLIMITED_LENGTHLnet/minecraft/client/gui/EditBox;UNLIMITED_LENGTH:Iintermediary field_39511Lnet/minecraft/class_7530;field_39511:Iofficial aLfjh;a:I
-
CURSOR_WIDTH
private static final int CURSOR_WIDTH- See Also:
- Mappings:
Namespace Name Mixin selector named CURSOR_WIDTHLnet/minecraft/client/gui/EditBox;CURSOR_WIDTH:Iintermediary field_39512Lnet/minecraft/class_7530;field_39512:Iofficial bLfjh;b:I
-
textRenderer
- Mappings:
Namespace Name Mixin selector named textRendererLnet/minecraft/client/gui/EditBox;textRenderer:Lnet/minecraft/client/font/TextRenderer;intermediary field_39513Lnet/minecraft/class_7530;field_39513:Lnet/minecraft/class_327;official cLfjh;c:Lfhx;
-
lines
- Mappings:
Namespace Name Mixin selector named linesLnet/minecraft/client/gui/EditBox;lines:Ljava/util/List;intermediary field_39514Lnet/minecraft/class_7530;field_39514:Ljava/util/List;official dLfjh;d:Ljava/util/List;
-
text
- Mappings:
Namespace Name Mixin selector named textLnet/minecraft/client/gui/EditBox;text:Ljava/lang/String;intermediary field_39515Lnet/minecraft/class_7530;field_39515:Ljava/lang/String;official eLfjh;e:Ljava/lang/String;
-
cursor
private int cursor- Mappings:
Namespace Name Mixin selector named cursorLnet/minecraft/client/gui/EditBox;cursor:Iintermediary field_39516Lnet/minecraft/class_7530;field_39516:Iofficial fLfjh;f:I
-
selectionEnd
private int selectionEnd- Mappings:
Namespace Name Mixin selector named selectionEndLnet/minecraft/client/gui/EditBox;selectionEnd:Iintermediary field_39517Lnet/minecraft/class_7530;field_39517:Iofficial gLfjh;g:I
-
selecting
private boolean selecting- Mappings:
Namespace Name Mixin selector named selectingLnet/minecraft/client/gui/EditBox;selecting:Zintermediary field_39518Lnet/minecraft/class_7530;field_39518:Zofficial hLfjh;h:Z
-
maxLength
private int maxLength- Mappings:
Namespace Name Mixin selector named maxLengthLnet/minecraft/client/gui/EditBox;maxLength:Iintermediary field_39519Lnet/minecraft/class_7530;field_39519:Iofficial iLfjh;i:I
-
width
private final int width- Mappings:
Namespace Name Mixin selector named widthLnet/minecraft/client/gui/EditBox;width:Iintermediary field_39520Lnet/minecraft/class_7530;field_39520:Iofficial jLfjh;j:I
-
changeListener
- Mappings:
Namespace Name Mixin selector named changeListenerLnet/minecraft/client/gui/EditBox;changeListener:Ljava/util/function/Consumer;intermediary field_39521Lnet/minecraft/class_7530;field_39521:Ljava/util/function/Consumer;official kLfjh;k:Ljava/util/function/Consumer;
-
cursorChangeListener
- Mappings:
Namespace Name Mixin selector named cursorChangeListenerLnet/minecraft/client/gui/EditBox;cursorChangeListener:Ljava/lang/Runnable;intermediary field_39522Lnet/minecraft/class_7530;field_39522:Ljava/lang/Runnable;official lLfjh;l:Ljava/lang/Runnable;
-
-
Constructor Details
-
EditBox
- Mappings:
Namespace Name Mixin selector named <init>Lnet/minecraft/client/gui/EditBox;<init>(Lnet/minecraft/client/font/TextRenderer;I)Vintermediary <init>Lnet/minecraft/class_7530;<init>(Lnet/minecraft/class_327;I)Vofficial <init>Lfjh;<init>(Lfhx;I)V
-
-
Method Details
-
getMaxLength
public int getMaxLength()Returns the maximum length of the edit box text in characters.If this equals
UNLIMITED_LENGTH, the edit box does not have a length limit. Edit box widgets with such edit boxes do not show the current text length indicator.- Returns:
- the maximum length of the edit box text in characters
- See Also:
- Mappings:
Namespace Name Mixin selector named getMaxLengthLnet/minecraft/client/gui/EditBox;getMaxLength()Iintermediary method_44409Lnet/minecraft/class_7530;method_44409()Iofficial aLfjh;a()I
-
setMaxLength
public void setMaxLength(int maxLength) Sets the maximum length of the edit box text in characters.If
maxLengthequalsUNLIMITED_LENGTH, the edit box does not have a length limit. Edit box widgets with such edit boxes do not show the current text length indicator.- Throws:
IllegalArgumentException- ifmaxLengthis negative- See Also:
- Mappings:
Namespace Name Mixin selector named setMaxLengthLnet/minecraft/client/gui/EditBox;setMaxLength(I)Vintermediary method_44411Lnet/minecraft/class_7530;method_44411(I)Vofficial aLfjh;a(I)V
-
hasMaxLength
public boolean hasMaxLength()Returns whether the edit box has a maximum length limit.Edit box widgets with edit boxes without a length limit do not show the current text length indicator.
- Returns:
- whether the edit box has a maximum length limit
- See Also:
- Mappings:
Namespace Name Mixin selector named hasMaxLengthLnet/minecraft/client/gui/EditBox;hasMaxLength()Zintermediary method_44418Lnet/minecraft/class_7530;method_44418()Zofficial bLfjh;b()Z
-
setChangeListener
Sets the change listener that is called every time the text changes.- Parameters:
changeListener- the listener that takes the new text of the edit box- Mappings:
Namespace Name Mixin selector named setChangeListenerLnet/minecraft/client/gui/EditBox;setChangeListener(Ljava/util/function/Consumer;)Vintermediary method_44415Lnet/minecraft/class_7530;method_44415(Ljava/util/function/Consumer;)Vofficial aLfjh;a(Ljava/util/function/Consumer;)V
-
setCursorChangeListener
Sets the cursor change listener that is called every time the cursor position changes.- Mappings:
Namespace Name Mixin selector named setCursorChangeListenerLnet/minecraft/client/gui/EditBox;setCursorChangeListener(Ljava/lang/Runnable;)Vintermediary method_44413Lnet/minecraft/class_7530;method_44413(Ljava/lang/Runnable;)Vofficial aLfjh;a(Ljava/lang/Runnable;)V
-
setText
Sets the text of the edit box and moves the cursor to the end of the edit box.- Mappings:
Namespace Name Mixin selector named setTextLnet/minecraft/client/gui/EditBox;setText(Ljava/lang/String;)Vintermediary method_44414Lnet/minecraft/class_7530;method_44414(Ljava/lang/String;)Vofficial aLfjh;a(Ljava/lang/String;)V
-
getText
Returns the text of the edit box.- Returns:
- the text of the edit box
- Mappings:
Namespace Name Mixin selector named getTextLnet/minecraft/client/gui/EditBox;getText()Ljava/lang/String;intermediary method_44421Lnet/minecraft/class_7530;method_44421()Ljava/lang/String;official cLfjh;c()Ljava/lang/String;
-
replaceSelection
Replaces the current selection withstring. If there is no selection, this inserts the string at the cursor position. This removes invalid characters and truncates the passed string if necessary.- Mappings:
Namespace Name Mixin selector named replaceSelectionLnet/minecraft/client/gui/EditBox;replaceSelection(Ljava/lang/String;)Vintermediary method_44420Lnet/minecraft/class_7530;method_44420(Ljava/lang/String;)Vofficial bLfjh;b(Ljava/lang/String;)V
-
delete
public void delete(int offset) Deletes the selected text, oroffsetcharacters of text from the cursor position if there is no selection. If the offset is negative, the characters before the cursor will be removed, and vice versa.- Mappings:
Namespace Name Mixin selector named deleteLnet/minecraft/client/gui/EditBox;delete(I)Vintermediary method_44419Lnet/minecraft/class_7530;method_44419(I)Vofficial bLfjh;b(I)V
-
getCursor
public int getCursor()Returns the cursor position.- Returns:
- the cursor position
- Mappings:
Namespace Name Mixin selector named getCursorLnet/minecraft/client/gui/EditBox;getCursor()Iintermediary method_44424Lnet/minecraft/class_7530;method_44424()Iofficial dLfjh;d()I
-
setSelecting
public void setSelecting(boolean selecting) Sets whether the edit box is currently selecting.If using the widget, this is done by dragging or holding down Shift and clicking.
- Mappings:
Namespace Name Mixin selector named setSelectingLnet/minecraft/client/gui/EditBox;setSelecting(Z)Vintermediary method_44417Lnet/minecraft/class_7530;method_44417(Z)Vofficial aLfjh;a(Z)V
-
getSelection
Returns the current selection.- Returns:
- the current selection
- Mappings:
Namespace Name Mixin selector named getSelectionLnet/minecraft/client/gui/EditBox;getSelection()Lnet/minecraft/client/gui/EditBox$Substring;intermediary method_44427Lnet/minecraft/class_7530;method_44427()Lnet/minecraft/class_7530$class_7531;official eLfjh;e()Lfjh$a;
-
getLineCount
public int getLineCount()Returns the number of total lines in the edit box.- Returns:
- the number of total lines in the edit box
- Mappings:
Namespace Name Mixin selector named getLineCountLnet/minecraft/client/gui/EditBox;getLineCount()Iintermediary method_44430Lnet/minecraft/class_7530;method_44430()Iofficial fLfjh;f()I
-
getCurrentLineIndex
public int getCurrentLineIndex()Returns the line index that the cursor is located at.- Returns:
- the line index that the cursor is located at
- Mappings:
Namespace Name Mixin selector named getCurrentLineIndexLnet/minecraft/client/gui/EditBox;getCurrentLineIndex()Iintermediary method_44432Lnet/minecraft/class_7530;method_44432()Iofficial gLfjh;g()I
-
getLine
Returns the line with indexindex.- Returns:
- the line with index
index - Mappings:
Namespace Name Mixin selector named getLineLnet/minecraft/client/gui/EditBox;getLine(I)Lnet/minecraft/client/gui/EditBox$Substring;intermediary method_44422Lnet/minecraft/class_7530;method_44422(I)Lnet/minecraft/class_7530$class_7531;official cLfjh;c(I)Lfjh$a;
-
moveCursor
Moves the cursor byamountcharacters.- API Note:
- See
CursorMovementfor the types of the movement. - Mappings:
Namespace Name Mixin selector named moveCursorLnet/minecraft/client/gui/EditBox;moveCursor(Lnet/minecraft/client/input/CursorMovement;I)Vintermediary method_44412Lnet/minecraft/class_7530;method_44412(Lnet/minecraft/class_7533;I)Vofficial aLfjh;a(Lfjy;I)V
-
moveCursorLine
public void moveCursorLine(int offset) Moves the cursor byoffsetlines. This method attempts to keep the relative position within the line the same. Does nothing ifoffsetis zero.- Mappings:
Namespace Name Mixin selector named moveCursorLineLnet/minecraft/client/gui/EditBox;moveCursorLine(I)Vintermediary method_44425Lnet/minecraft/class_7530;method_44425(I)Vofficial dLfjh;d(I)V
-
moveCursor
public void moveCursor(double x, double y) Moves the cursor to the specified position relative to the edit box.- Mappings:
Namespace Name Mixin selector named moveCursorLnet/minecraft/client/gui/EditBox;moveCursor(DD)Vintermediary method_44410Lnet/minecraft/class_7530;method_44410(DD)Vofficial aLfjh;a(DD)V
-
handleSpecialKey
public boolean handleSpecialKey(int keyCode) Handles the special keys, such as copy, cut, linebreak, and cursor movements.- Mappings:
Namespace Name Mixin selector named handleSpecialKeyLnet/minecraft/client/gui/EditBox;handleSpecialKey(I)Zintermediary method_44428Lnet/minecraft/class_7530;method_44428(I)Zofficial eLfjh;e(I)Z
-
getLines
Returns the lines of the edit box's text.- Returns:
- the lines of the edit box's text
- Mappings:
Namespace Name Mixin selector named getLinesLnet/minecraft/client/gui/EditBox;getLines()Ljava/lang/Iterable;intermediary method_44434Lnet/minecraft/class_7530;method_44434()Ljava/lang/Iterable;official hLfjh;h()Ljava/lang/Iterable;
-
hasSelection
public boolean hasSelection()Returns whether the edit box has a selected text.- Returns:
- whether the edit box has a selected text
- Mappings:
Namespace Name Mixin selector named hasSelectionLnet/minecraft/client/gui/EditBox;hasSelection()Zintermediary method_44435Lnet/minecraft/class_7530;method_44435()Zofficial iLfjh;i()Z
-
getSelectedText
Returns the text that is currently selected, or an empty string if there is no selection.- Returns:
- the text that is currently selected, or an empty string if there is no selection
- Mappings:
Namespace Name Mixin selector named getSelectedTextLnet/minecraft/client/gui/EditBox;getSelectedText()Ljava/lang/String;intermediary method_44436Lnet/minecraft/class_7530;method_44436()Ljava/lang/String;official jLfjh;j()Ljava/lang/String;
-
getCurrentLine
Returns the line that the cursor is located at.- Returns:
- the line that the cursor is located at
- Mappings:
Namespace Name Mixin selector named getCurrentLineLnet/minecraft/client/gui/EditBox;getCurrentLine()Lnet/minecraft/client/gui/EditBox$Substring;intermediary method_44439Lnet/minecraft/class_7530;method_44439()Lnet/minecraft/class_7530$class_7531;official mLfjh;m()Lfjh$a;
-
getOffsetLine
Returns the line offset byoffsetFromCurrentfrom the cursor's line.- Returns:
- the line offset by
offsetFromCurrentfrom the cursor's line - Mappings:
Namespace Name Mixin selector named getOffsetLineLnet/minecraft/client/gui/EditBox;getOffsetLine(I)Lnet/minecraft/client/gui/EditBox$Substring;intermediary method_44431Lnet/minecraft/class_7530;method_44431(I)Lnet/minecraft/class_7530$class_7531;official fLfjh;f(I)Lfjh$a;
-
getPreviousWordAtCursor
Returns the substring of a word whose start position is before the cursor.A word is a string consisting entirely of non-whitespace characters. If the cursor is in the middle of a word, the start position is that of the word; if not, the start position is that of the first word before the cursor.
- Returns:
- the substring of a word whose start position is before the cursor
- See Also:
- Mappings:
Namespace Name Mixin selector named getPreviousWordAtCursorLnet/minecraft/client/gui/EditBox;getPreviousWordAtCursor()Lnet/minecraft/client/gui/EditBox$Substring;intermediary method_44437Lnet/minecraft/class_7530;method_44437()Lnet/minecraft/class_7530$class_7531;official kLfjh;k()Lfjh$a;
-
getNextWordAtCursor
Returns the substring of a word whose start position is after the cursor.A word is a string consisting entirely of non-whitespace characters. If the cursor is in the middle of a word, the start position is that of the first word after the cursor; if not, the start position is that of the next word.
- Returns:
- the substring of a word whose start position is after the cursor
- See Also:
- Mappings:
Namespace Name Mixin selector named getNextWordAtCursorLnet/minecraft/client/gui/EditBox;getNextWordAtCursor()Lnet/minecraft/client/gui/EditBox$Substring;intermediary method_44438Lnet/minecraft/class_7530;method_44438()Lnet/minecraft/class_7530$class_7531;official lLfjh;l()Lfjh$a;
-
getWordEndIndex
private int getWordEndIndex(int startIndex) Returns the end index of the word starting atstartIndex.A word is a string consisting entirely of non-whitespace characters. Therefore, the end index is the index of the character whose succeeding character is the first whitespace since
startIndex.- Returns:
- the end index of the word starting at
startIndex - Mappings:
Namespace Name Mixin selector named getWordEndIndexLnet/minecraft/client/gui/EditBox;getWordEndIndex(I)Iintermediary method_44433Lnet/minecraft/class_7530;method_44433(I)Iofficial gLfjh;g(I)I
-
onChange
private void onChange()Called when the text changes. This rewraps the text, callschangeListener, then callscursorChangeListener.- Mappings:
Namespace Name Mixin selector named onChangeLnet/minecraft/client/gui/EditBox;onChange()Vintermediary method_44440Lnet/minecraft/class_7530;method_44440()Vofficial nLfjh;n()V
-
rewrap
private void rewrap()Rewraps the text. This is called whenever the text changes.- Mappings:
Namespace Name Mixin selector named rewrapLnet/minecraft/client/gui/EditBox;rewrap()Vintermediary method_44441Lnet/minecraft/class_7530;method_44441()Vofficial oLfjh;o()V
-
truncateForReplacement
Returnsvaluetruncated to at mostmaxLengthcharacters.- Returns:
valuetruncated to at mostmaxLengthcharacters- See Also:
- Mappings:
Namespace Name Mixin selector named truncateForReplacementLnet/minecraft/client/gui/EditBox;truncateForReplacement(Ljava/lang/String;)Ljava/lang/String;intermediary method_44423Lnet/minecraft/class_7530;method_44423(Ljava/lang/String;)Ljava/lang/String;official cLfjh;c(Ljava/lang/String;)Ljava/lang/String;
-
truncate
Returnsvaluetruncated to fit in the current text.For example, if the edit box with 100 characters limit currently has 90 characters, this method will return at most 10 characters.
- Returns:
valuetruncated to fit in the current text- See Also:
- Mappings:
Namespace Name Mixin selector named truncateLnet/minecraft/client/gui/EditBox;truncate(Ljava/lang/String;)Ljava/lang/String;intermediary method_44426Lnet/minecraft/class_7530;method_44426(Ljava/lang/String;)Ljava/lang/String;official dLfjh;d(Ljava/lang/String;)Ljava/lang/String;
-