Class EditBox
EditBoxWidget
provides the GUI for the edit box.- Mappings:
Namespace Name official eqb
intermediary net/minecraft/class_7530
named net/minecraft/client/gui/EditBox
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static final record
A substring of an edit box's text, specified using the indices of the start and the end. -
Field Summary
Modifier and TypeFieldDescriptionprivate int
private static final int
private Runnable
private final List<EditBox.Substring>
private int
private boolean
private int
private String
private final TextRenderer
static final int
A constant denoting that the edit box accepts unlimited amount of text.private final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
delete
(int offset) Deletes the selected text, oroffset
characters of text from the cursor position if there is no selection.private EditBox.Substring
Returns the line that the cursor is located at.int
Returns the line index that the cursor is located at.int
Returns the cursor position.getLine
(int index) Returns the line with indexindex
.int
Returns the number of total lines in the edit box.getLines()
Returns the lines of the edit box's text.int
Returns 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.Substring
getOffsetLine
(int offsetFromCurrent) Returns the line offset byoffsetFromCurrent
from 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 int
getWordEndIndex
(int startIndex) Returns the end index of the word starting atstartIndex
.boolean
handleSpecialKey
(int keyCode) Handles the special keys, such as copy, cut, linebreak, and cursor movements.boolean
Returns whether the edit box has a maximum length limit.boolean
Returns whether the edit box has a selected text.void
moveCursor
(double x, double y) Moves the cursor to the specified position relative to the edit box.void
moveCursor
(CursorMovement movement, int amount) Moves the cursor byamount
characters.void
moveCursorLine
(int offset) Moves the cursor byoffset
lines.private void
onChange()
Called when the text changes.void
replaceSelection
(String string) Replaces the current selection withstring
.private void
rewrap()
Rewraps the text.void
setChangeListener
(Consumer<String> changeListener) Sets the change listener that is called every time the text changes.void
setCursorChangeListener
(Runnable cursorChangeListener) Sets the cursor change listener that is called every time the cursor position changes.void
setMaxLength
(int maxLength) Sets the maximum length of the edit box text in characters.void
setSelecting
(boolean selecting) Sets whether the edit box is currently selecting.void
Sets the text of the edit box and moves the cursor to the end of the edit box.private String
Returnsvalue
truncated to fit in the current text.private String
truncateForReplacement
(String value) Returnsvalue
truncated to at mostmaxLength
characters.
-
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 official a
Leqb;a:I
intermediary field_39511
Lnet/minecraft/class_7530;field_39511:I
named UNLIMITED_LENGTH
Lnet/minecraft/client/gui/EditBox;UNLIMITED_LENGTH:I
-
CURSOR_WIDTH
private static final int CURSOR_WIDTH- See Also:
- Mappings:
Namespace Name Mixin selector official b
Leqb;b:I
intermediary field_39512
Lnet/minecraft/class_7530;field_39512:I
named CURSOR_WIDTH
Lnet/minecraft/client/gui/EditBox;CURSOR_WIDTH:I
-
textRenderer
- Mappings:
Namespace Name Mixin selector official c
Leqb;c:Leov;
intermediary field_39513
Lnet/minecraft/class_7530;field_39513:Lnet/minecraft/class_327;
named textRenderer
Lnet/minecraft/client/gui/EditBox;textRenderer:Lnet/minecraft/client/font/TextRenderer;
-
lines
- Mappings:
Namespace Name Mixin selector official d
Leqb;d:Ljava/util/List;
intermediary field_39514
Lnet/minecraft/class_7530;field_39514:Ljava/util/List;
named lines
Lnet/minecraft/client/gui/EditBox;lines:Ljava/util/List;
-
text
- Mappings:
Namespace Name Mixin selector official e
Leqb;e:Ljava/lang/String;
intermediary field_39515
Lnet/minecraft/class_7530;field_39515:Ljava/lang/String;
named text
Lnet/minecraft/client/gui/EditBox;text:Ljava/lang/String;
-
cursor
private int cursor- Mappings:
Namespace Name Mixin selector official f
Leqb;f:I
intermediary field_39516
Lnet/minecraft/class_7530;field_39516:I
named cursor
Lnet/minecraft/client/gui/EditBox;cursor:I
-
selectionEnd
private int selectionEnd- Mappings:
Namespace Name Mixin selector official g
Leqb;g:I
intermediary field_39517
Lnet/minecraft/class_7530;field_39517:I
named selectionEnd
Lnet/minecraft/client/gui/EditBox;selectionEnd:I
-
selecting
private boolean selecting- Mappings:
Namespace Name Mixin selector official h
Leqb;h:Z
intermediary field_39518
Lnet/minecraft/class_7530;field_39518:Z
named selecting
Lnet/minecraft/client/gui/EditBox;selecting:Z
-
maxLength
private int maxLength- Mappings:
Namespace Name Mixin selector official i
Leqb;i:I
intermediary field_39519
Lnet/minecraft/class_7530;field_39519:I
named maxLength
Lnet/minecraft/client/gui/EditBox;maxLength:I
-
width
private final int width- Mappings:
Namespace Name Mixin selector official j
Leqb;j:I
intermediary field_39520
Lnet/minecraft/class_7530;field_39520:I
named width
Lnet/minecraft/client/gui/EditBox;width:I
-
changeListener
- Mappings:
Namespace Name Mixin selector official k
Leqb;k:Ljava/util/function/Consumer;
intermediary field_39521
Lnet/minecraft/class_7530;field_39521:Ljava/util/function/Consumer;
named changeListener
Lnet/minecraft/client/gui/EditBox;changeListener:Ljava/util/function/Consumer;
-
cursorChangeListener
- Mappings:
Namespace Name Mixin selector official l
Leqb;l:Ljava/lang/Runnable;
intermediary field_39522
Lnet/minecraft/class_7530;field_39522:Ljava/lang/Runnable;
named cursorChangeListener
Lnet/minecraft/client/gui/EditBox;cursorChangeListener:Ljava/lang/Runnable;
-
-
Constructor Details
-
EditBox
- Mappings:
Namespace Name Mixin selector official <init>
Leqb;<init>(Leov;I)V
intermediary <init>
Lnet/minecraft/class_7530;<init>(Lnet/minecraft/class_327;I)V
named <init>
Lnet/minecraft/client/gui/EditBox;<init>(Lnet/minecraft/client/font/TextRenderer;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 official a
Leqb;a()I
intermediary method_44409
Lnet/minecraft/class_7530;method_44409()I
named getMaxLength
Lnet/minecraft/client/gui/EditBox;getMaxLength()I
-
setMaxLength
public void setMaxLength(int maxLength) Sets the maximum length of the edit box text in characters.If
maxLength
equalsUNLIMITED_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
- ifmaxLength
is negative- See Also:
- Mappings:
Namespace Name Mixin selector official a
Leqb;a(I)V
intermediary method_44411
Lnet/minecraft/class_7530;method_44411(I)V
named setMaxLength
Lnet/minecraft/client/gui/EditBox;setMaxLength(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 official b
Leqb;b()Z
intermediary method_44418
Lnet/minecraft/class_7530;method_44418()Z
named hasMaxLength
Lnet/minecraft/client/gui/EditBox;hasMaxLength()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 official a
Leqb;a(Ljava/util/function/Consumer;)V
intermediary method_44415
Lnet/minecraft/class_7530;method_44415(Ljava/util/function/Consumer;)V
named setChangeListener
Lnet/minecraft/client/gui/EditBox;setChangeListener(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 official a
Leqb;a(Ljava/lang/Runnable;)V
intermediary method_44413
Lnet/minecraft/class_7530;method_44413(Ljava/lang/Runnable;)V
named setCursorChangeListener
Lnet/minecraft/client/gui/EditBox;setCursorChangeListener(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 official a
Leqb;a(Ljava/lang/String;)V
intermediary method_44414
Lnet/minecraft/class_7530;method_44414(Ljava/lang/String;)V
named setText
Lnet/minecraft/client/gui/EditBox;setText(Ljava/lang/String;)V
-
getText
Returns the text of the edit box.- Returns:
- the text of the edit box
- Mappings:
Namespace Name Mixin selector official c
Leqb;c()Ljava/lang/String;
intermediary method_44421
Lnet/minecraft/class_7530;method_44421()Ljava/lang/String;
named getText
Lnet/minecraft/client/gui/EditBox;getText()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 official b
Leqb;b(Ljava/lang/String;)V
intermediary method_44420
Lnet/minecraft/class_7530;method_44420(Ljava/lang/String;)V
named replaceSelection
Lnet/minecraft/client/gui/EditBox;replaceSelection(Ljava/lang/String;)V
-
delete
public void delete(int offset) Deletes the selected text, oroffset
characters 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 official b
Leqb;b(I)V
intermediary method_44419
Lnet/minecraft/class_7530;method_44419(I)V
named delete
Lnet/minecraft/client/gui/EditBox;delete(I)V
-
getCursor
public int getCursor()Returns the cursor position.- Returns:
- the cursor position
- Mappings:
Namespace Name Mixin selector official d
Leqb;d()I
intermediary method_44424
Lnet/minecraft/class_7530;method_44424()I
named getCursor
Lnet/minecraft/client/gui/EditBox;getCursor()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 official a
Leqb;a(Z)V
intermediary method_44417
Lnet/minecraft/class_7530;method_44417(Z)V
named setSelecting
Lnet/minecraft/client/gui/EditBox;setSelecting(Z)V
-
getSelection
Returns the current selection.- Returns:
- the current selection
- Mappings:
Namespace Name Mixin selector official e
Leqb;e()Leqb$a;
intermediary method_44427
Lnet/minecraft/class_7530;method_44427()Lnet/minecraft/class_7530$class_7531;
named getSelection
Lnet/minecraft/client/gui/EditBox;getSelection()Lnet/minecraft/client/gui/EditBox$Substring;
-
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 official f
Leqb;f()I
intermediary method_44430
Lnet/minecraft/class_7530;method_44430()I
named getLineCount
Lnet/minecraft/client/gui/EditBox;getLineCount()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 official g
Leqb;g()I
intermediary method_44432
Lnet/minecraft/class_7530;method_44432()I
named getCurrentLineIndex
Lnet/minecraft/client/gui/EditBox;getCurrentLineIndex()I
-
getLine
Returns the line with indexindex
.- Returns:
- the line with index
index
- Mappings:
Namespace Name Mixin selector official c
Leqb;c(I)Leqb$a;
intermediary method_44422
Lnet/minecraft/class_7530;method_44422(I)Lnet/minecraft/class_7530$class_7531;
named getLine
Lnet/minecraft/client/gui/EditBox;getLine(I)Lnet/minecraft/client/gui/EditBox$Substring;
-
moveCursor
Moves the cursor byamount
characters.- API Note:
- See
CursorMovement
for the types of the movement. - Mappings:
Namespace Name Mixin selector official a
Leqb;a(Leqq;I)V
intermediary method_44412
Lnet/minecraft/class_7530;method_44412(Lnet/minecraft/class_7533;I)V
named moveCursor
Lnet/minecraft/client/gui/EditBox;moveCursor(Lnet/minecraft/client/input/CursorMovement;I)V
-
moveCursorLine
public void moveCursorLine(int offset) Moves the cursor byoffset
lines. This method attempts to keep the relative position within the line the same. Does nothing ifoffset
is zero.- Mappings:
Namespace Name Mixin selector official d
Leqb;d(I)V
intermediary method_44425
Lnet/minecraft/class_7530;method_44425(I)V
named moveCursorLine
Lnet/minecraft/client/gui/EditBox;moveCursorLine(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 official a
Leqb;a(DD)V
intermediary method_44410
Lnet/minecraft/class_7530;method_44410(DD)V
named moveCursor
Lnet/minecraft/client/gui/EditBox;moveCursor(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 official e
Leqb;e(I)Z
intermediary method_44428
Lnet/minecraft/class_7530;method_44428(I)Z
named handleSpecialKey
Lnet/minecraft/client/gui/EditBox;handleSpecialKey(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 official h
Leqb;h()Ljava/lang/Iterable;
intermediary method_44434
Lnet/minecraft/class_7530;method_44434()Ljava/lang/Iterable;
named getLines
Lnet/minecraft/client/gui/EditBox;getLines()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 official i
Leqb;i()Z
intermediary method_44435
Lnet/minecraft/class_7530;method_44435()Z
named hasSelection
Lnet/minecraft/client/gui/EditBox;hasSelection()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 official j
Leqb;j()Ljava/lang/String;
intermediary method_44436
Lnet/minecraft/class_7530;method_44436()Ljava/lang/String;
named getSelectedText
Lnet/minecraft/client/gui/EditBox;getSelectedText()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 official m
Leqb;m()Leqb$a;
intermediary method_44439
Lnet/minecraft/class_7530;method_44439()Lnet/minecraft/class_7530$class_7531;
named getCurrentLine
Lnet/minecraft/client/gui/EditBox;getCurrentLine()Lnet/minecraft/client/gui/EditBox$Substring;
-
getOffsetLine
Returns the line offset byoffsetFromCurrent
from the cursor's line.- Returns:
- the line offset by
offsetFromCurrent
from the cursor's line - Mappings:
Namespace Name Mixin selector official f
Leqb;f(I)Leqb$a;
intermediary method_44431
Lnet/minecraft/class_7530;method_44431(I)Lnet/minecraft/class_7530$class_7531;
named getOffsetLine
Lnet/minecraft/client/gui/EditBox;getOffsetLine(I)Lnet/minecraft/client/gui/EditBox$Substring;
-
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 official k
Leqb;k()Leqb$a;
intermediary method_44437
Lnet/minecraft/class_7530;method_44437()Lnet/minecraft/class_7530$class_7531;
named getPreviousWordAtCursor
Lnet/minecraft/client/gui/EditBox;getPreviousWordAtCursor()Lnet/minecraft/client/gui/EditBox$Substring;
-
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 official l
Leqb;l()Leqb$a;
intermediary method_44438
Lnet/minecraft/class_7530;method_44438()Lnet/minecraft/class_7530$class_7531;
named getNextWordAtCursor
Lnet/minecraft/client/gui/EditBox;getNextWordAtCursor()Lnet/minecraft/client/gui/EditBox$Substring;
-
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 official g
Leqb;g(I)I
intermediary method_44433
Lnet/minecraft/class_7530;method_44433(I)I
named getWordEndIndex
Lnet/minecraft/client/gui/EditBox;getWordEndIndex(I)I
-
onChange
private void onChange()Called when the text changes. This rewraps the text, callschangeListener
, then callscursorChangeListener
.- Mappings:
Namespace Name Mixin selector official n
Leqb;n()V
intermediary method_44440
Lnet/minecraft/class_7530;method_44440()V
named onChange
Lnet/minecraft/client/gui/EditBox;onChange()V
-
rewrap
private void rewrap()Rewraps the text. This is called whenever the text changes.- Mappings:
Namespace Name Mixin selector official o
Leqb;o()V
intermediary method_44441
Lnet/minecraft/class_7530;method_44441()V
named rewrap
Lnet/minecraft/client/gui/EditBox;rewrap()V
-
truncateForReplacement
Returnsvalue
truncated to at mostmaxLength
characters.- Returns:
value
truncated to at mostmaxLength
characters- See Also:
- Mappings:
Namespace Name Mixin selector official c
Leqb;c(Ljava/lang/String;)Ljava/lang/String;
intermediary method_44423
Lnet/minecraft/class_7530;method_44423(Ljava/lang/String;)Ljava/lang/String;
named truncateForReplacement
Lnet/minecraft/client/gui/EditBox;truncateForReplacement(Ljava/lang/String;)Ljava/lang/String;
-
truncate
Returnsvalue
truncated 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:
value
truncated to fit in the current text- See Also:
- Mappings:
Namespace Name Mixin selector official d
Leqb;d(Ljava/lang/String;)Ljava/lang/String;
intermediary method_44426
Lnet/minecraft/class_7530;method_44426(Ljava/lang/String;)Ljava/lang/String;
named truncate
Lnet/minecraft/client/gui/EditBox;truncate(Ljava/lang/String;)Ljava/lang/String;
-