Package net.minecraft.client.gui.widget
Class EditBoxWidget
java.lang.Object
net.minecraft.client.gui.widget.ClickableWidget
net.minecraft.client.gui.widget.ScrollableWidget
net.minecraft.client.gui.widget.EditBoxWidget
- All Implemented Interfaces:
Drawable,Element,Narratable,Navigable,Selectable,Widget
A widget of
EditBox, a multiline edit box with support for
basic keyboard shortcuts. This class implements the rendering and scrolling
for the edit box.- Mappings:
Namespace Name official eppintermediary net/minecraft/class_7529named net/minecraft/client/gui/widget/EditBoxWidget
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.client.gui.Selectable
Selectable.SelectionType -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate final EditBoxprivate static final intprivate final TextThe placeholder text that gets rendered when the edit box is empty.private final TextRendererprivate intprivate static final Stringprivate static final intFields inherited from class net.minecraft.client.gui.widget.ClickableWidget
ACCESSIBILITY_TEXTURE, active, alpha, height, hovered, visible, WIDGETS_TEXTURE, widthFields inherited from interface net.minecraft.client.gui.Element
MAX_DOUBLE_CLICK_INTERVAL -
Constructor Summary
ConstructorsConstructorDescriptionEditBoxWidget(TextRenderer textRenderer, int x, int y, int width, int height, Text placeholder, Text message) -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleancharTyped(char chr, int modifiers) Callback for when a character input has been captured.private voiddrawSelection(DrawContext context, int left, int top, int right, int bottom) intReturns the total height of the contents.protected doubleprivate doubleReturns the maximum amount of lines the widget can hold without overflowing.getText()Returns the current text of the edit box.booleankeyPressed(int keyCode, int scanCode, int modifiers) Callback for when a key down event has been captured.booleanmouseClicked(double mouseX, double mouseY, int button) Callback for when a mouse button down event has been captured.booleanmouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) Callback for when a mouse button drag event has been captured.private voidmoveCursor(double mouseX, double mouseY) private voidprotected booleanReturns whether the contents overflow and needs a scrollbar.protected voidrenderContents(DrawContext context, int mouseX, int mouseY, float delta) Renders the scrolled contents.protected voidrenderOverlay(DrawContext context) Renders overlays that are not scrolled but part of the widget.voidsetChangeListener(Consumer<String> changeListener) Sets the change listener that is called every time the text changes.voidsetMaxLength(int maxLength) Sets the maximum length of the edit box text in characters.voidSets the text of the edit box and moves the cursor to the end of the edit box.voidtick()Methods inherited from class net.minecraft.client.gui.widget.ScrollableWidget
getMaxScrollY, getPadding, getPaddingDoubled, getScrollY, isVisible, isWithinBounds, mouseReleased, mouseScrolled, renderButton, setScrollYMethods inherited from class net.minecraft.client.gui.widget.ClickableWidget
appendDefaultNarrations, appendNarrations, clicked, drawScrollableText, drawScrollableText, drawTexture, forEachChild, getHeight, getMessage, getNarrationMessage, getNarrationMessage, getNavigationFocus, getNavigationOrder, getNavigationPath, getTooltip, getTooltipPositioner, getType, getWidth, getX, getY, isFocused, isHovered, isMouseOver, isNarratable, isSelected, isValidClickButton, onClick, onDrag, onRelease, playDownSound, render, setAlpha, setFocused, setMessage, setNavigationOrder, setTooltip, setTooltipDelay, setWidth, setX, setYMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.client.gui.Element
getFocusedPath, getNavigationFocus, getNavigationPath, isFocused, isMouseOver, keyReleased, mouseMoved, setFocusedMethods inherited from interface net.minecraft.client.gui.navigation.Navigable
getNavigationOrderMethods inherited from interface net.minecraft.client.gui.widget.Widget
setPosition
-
Field Details
-
CURSOR_PADDING
private static final int CURSOR_PADDING- See Also:
- Mappings:
Namespace Name Mixin selector official aLepp;a:Iintermediary field_39502Lnet/minecraft/class_7529;field_39502:Inamed CURSOR_PADDINGLnet/minecraft/client/gui/widget/EditBoxWidget;CURSOR_PADDING:I
-
CURSOR_COLOR
private static final int CURSOR_COLOR- See Also:
- Mappings:
Namespace Name Mixin selector official bLepp;b:Iintermediary field_39503Lnet/minecraft/class_7529;field_39503:Inamed CURSOR_COLORLnet/minecraft/client/gui/widget/EditBoxWidget;CURSOR_COLOR:I
-
UNDERSCORE
- See Also:
- Mappings:
Namespace Name Mixin selector official cLepp;c:Ljava/lang/String;intermediary field_39504Lnet/minecraft/class_7529;field_39504:Ljava/lang/String;named UNDERSCORELnet/minecraft/client/gui/widget/EditBoxWidget;UNDERSCORE:Ljava/lang/String;
-
FOCUSED_BOX_TEXT_COLOR
private static final int FOCUSED_BOX_TEXT_COLOR- See Also:
- Mappings:
Namespace Name Mixin selector official dLepp;d:Iintermediary field_39505Lnet/minecraft/class_7529;field_39505:Inamed FOCUSED_BOX_TEXT_COLORLnet/minecraft/client/gui/widget/EditBoxWidget;FOCUSED_BOX_TEXT_COLOR:I
-
UNFOCUSED_BOX_TEXT_COLOR
private static final int UNFOCUSED_BOX_TEXT_COLOR- See Also:
- Mappings:
Namespace Name Mixin selector official eLepp;e:Iintermediary field_39506Lnet/minecraft/class_7529;field_39506:Inamed UNFOCUSED_BOX_TEXT_COLORLnet/minecraft/client/gui/widget/EditBoxWidget;UNFOCUSED_BOX_TEXT_COLOR:I
-
textRenderer
- Mappings:
Namespace Name Mixin selector official fLepp;f:Leon;intermediary field_39507Lnet/minecraft/class_7529;field_39507:Lnet/minecraft/class_327;named textRendererLnet/minecraft/client/gui/widget/EditBoxWidget;textRenderer:Lnet/minecraft/client/font/TextRenderer;
-
placeholder
The placeholder text that gets rendered when the edit box is empty. This does not get returned fromgetText(); an empty string will be returned in such cases.- Mappings:
Namespace Name Mixin selector official gLepp;g:Lsw;intermediary field_39508Lnet/minecraft/class_7529;field_39508:Lnet/minecraft/class_2561;named placeholderLnet/minecraft/client/gui/widget/EditBoxWidget;placeholder:Lnet/minecraft/text/Text;
-
editBox
- Mappings:
Namespace Name Mixin selector official hLepp;h:Leps;intermediary field_39509Lnet/minecraft/class_7529;field_39509:Lnet/minecraft/class_7530;named editBoxLnet/minecraft/client/gui/widget/EditBoxWidget;editBox:Lnet/minecraft/client/gui/EditBox;
-
tick
private int tick- Mappings:
Namespace Name Mixin selector official iLepp;i:Iintermediary field_39510Lnet/minecraft/class_7529;field_39510:Inamed tickLnet/minecraft/client/gui/widget/EditBoxWidget;tick:I
-
-
Constructor Details
-
EditBoxWidget
public EditBoxWidget(TextRenderer textRenderer, int x, int y, int width, int height, Text placeholder, Text message) - Mappings:
Namespace Name Mixin selector official <init>Lepp;<init>(Leon;IIIILsw;Lsw;)Vintermediary <init>Lnet/minecraft/class_7529;<init>(Lnet/minecraft/class_327;IIIILnet/minecraft/class_2561;Lnet/minecraft/class_2561;)Vnamed <init>Lnet/minecraft/client/gui/widget/EditBoxWidget;<init>(Lnet/minecraft/client/font/TextRenderer;IIIILnet/minecraft/text/Text;Lnet/minecraft/text/Text;)V
-
-
Method Details
-
setMaxLength
public void setMaxLength(int maxLength) Sets the maximum length of the edit box text in characters.If
maxLengthequalsEditBox.UNLIMITED_LENGTH, the edit box does not have a length limit, and the widget does not show the current text length indicator.- Throws:
IllegalArgumentException- ifmaxLengthis negative- See Also:
- Mappings:
Namespace Name Mixin selector official aLepp;a(I)Vintermediary method_44402Lnet/minecraft/class_7529;method_44402(I)Vnamed setMaxLengthLnet/minecraft/client/gui/widget/EditBoxWidget;setMaxLength(I)V
-
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 bLepp;b(Ljava/util/function/Consumer;)Vintermediary method_44401Lnet/minecraft/class_7529;method_44401(Ljava/util/function/Consumer;)Vnamed setChangeListenerLnet/minecraft/client/gui/widget/EditBoxWidget;setChangeListener(Ljava/util/function/Consumer;)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 aLepp;a(Ljava/lang/String;)Vintermediary method_44400Lnet/minecraft/class_7529;method_44400(Ljava/lang/String;)Vnamed setTextLnet/minecraft/client/gui/widget/EditBoxWidget;setText(Ljava/lang/String;)V
-
getText
Returns the current text of the edit box.- Returns:
- the current text of the edit box
- Mappings:
Namespace Name Mixin selector official uLepp;u()Ljava/lang/String;intermediary method_44405Lnet/minecraft/class_7529;method_44405()Ljava/lang/String;named getTextLnet/minecraft/client/gui/widget/EditBoxWidget;getText()Ljava/lang/String;
-
tick
public void tick()- Mappings:
Namespace Name Mixin selector official vLepp;v()Vintermediary method_44406Lnet/minecraft/class_7529;method_44406()Vnamed tickLnet/minecraft/client/gui/widget/EditBoxWidget;tick()V
-
appendClickableNarrations
- Specified by:
appendClickableNarrationsin classClickableWidget- Mappings:
Namespace Name Mixin selector official aLeox;a(Lesg;)Vintermediary method_47399Lnet/minecraft/class_339;method_47399(Lnet/minecraft/class_6382;)Vnamed appendClickableNarrationsLnet/minecraft/client/gui/widget/ClickableWidget;appendClickableNarrations(Lnet/minecraft/client/gui/screen/narration/NarrationMessageBuilder;)V
-
mouseClicked
public boolean mouseClicked(double mouseX, double mouseY, int button) Callback for when a mouse button down event has been captured. The button number is identified by the constants inGLFWclass.- Specified by:
mouseClickedin interfaceElement- Overrides:
mouseClickedin classScrollableWidget- Parameters:
mouseX- the X coordinate of the mousemouseY- the Y coordinate of the mousebutton- the mouse button number- Returns:
trueto indicate that the event handling is successful/valid- See Also:
- Mappings:
Namespace Name Mixin selector official aLeqk;a(DDI)Zintermediary method_25402Lnet/minecraft/class_364;method_25402(DDI)Znamed mouseClickedLnet/minecraft/client/gui/Element;mouseClicked(DDI)Z
-
mouseDragged
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) Callback for when a mouse button drag event has been captured. The button number is identified by the constants inGLFWclass.- Specified by:
mouseDraggedin interfaceElement- Overrides:
mouseDraggedin classScrollableWidget- Parameters:
mouseX- the current X coordinate of the mousemouseY- the current Y coordinate of the mousebutton- the mouse button numberdeltaX- the difference of the current X with the previous X coordinatedeltaY- the difference of the current Y with the previous Y coordinate- Returns:
trueto indicate that the event handling is successful/valid- See Also:
- Mappings:
Namespace Name Mixin selector official aLeqk;a(DDIDD)Zintermediary method_25403Lnet/minecraft/class_364;method_25403(DDIDD)Znamed mouseDraggedLnet/minecraft/client/gui/Element;mouseDragged(DDIDD)Z
-
keyPressed
public boolean keyPressed(int keyCode, int scanCode, int modifiers) Callback for when a key down event has been captured. The key code is identified by the constants inGLFWclass.- Specified by:
keyPressedin interfaceElement- Overrides:
keyPressedin classScrollableWidget- Parameters:
keyCode- the named key code of the event as described in theGLFWclassscanCode- the unique/platform-specific scan code of the keyboard inputmodifiers- a GLFW bitfield describing the modifier keys that are held down (see GLFW Modifier key flags)- Returns:
trueto indicate that the event handling is successful/valid- See Also:
- Mappings:
Namespace Name Mixin selector official aLeqk;a(III)Zintermediary method_25404Lnet/minecraft/class_364;method_25404(III)Znamed keyPressedLnet/minecraft/client/gui/Element;keyPressed(III)Z
-
charTyped
public boolean charTyped(char chr, int modifiers) Callback for when a character input has been captured. The key code is identified by the constants inGLFWclass.- Parameters:
chr- the captured charactermodifiers- a GLFW bitfield describing the modifier keys that are held down (see GLFW Modifier key flags)- Returns:
trueto indicate that the event handling is successful/valid- See Also:
- Mappings:
Namespace Name Mixin selector official aLeqk;a(CI)Zintermediary method_25400Lnet/minecraft/class_364;method_25400(CI)Znamed charTypedLnet/minecraft/client/gui/Element;charTyped(CI)Z
-
renderContents
Renders the scrolled contents. Subclasses must override this. The rendered contents may overflow; the caller should trim those usingDrawContext.enableScissor(int, int, int, int).- Specified by:
renderContentsin classScrollableWidget- Mappings:
Namespace Name Mixin selector official cLeot;c(Leop;IIF)Vintermediary method_44389Lnet/minecraft/class_7528;method_44389(Lnet/minecraft/class_332;IIF)Vnamed renderContentsLnet/minecraft/client/gui/widget/ScrollableWidget;renderContents(Lnet/minecraft/client/gui/DrawContext;IIF)V
-
renderOverlay
Renders overlays that are not scrolled but part of the widget.This renders the scrollbar by default. Subclasses can override this to render other overlays, but
supercall is necessary to make sure the scrollbar renders when it should.- Overrides:
renderOverlayin classScrollableWidget- Mappings:
Namespace Name Mixin selector official aLeot;a(Leop;)Vintermediary method_44384Lnet/minecraft/class_7528;method_44384(Lnet/minecraft/class_332;)Vnamed renderOverlayLnet/minecraft/client/gui/widget/ScrollableWidget;renderOverlay(Lnet/minecraft/client/gui/DrawContext;)V
-
getContentsHeight
public int getContentsHeight()Returns the total height of the contents.- Specified by:
getContentsHeightin classScrollableWidget- Returns:
- the total height of the contents
- Mappings:
Namespace Name Mixin selector official eLeot;e()Iintermediary method_44391Lnet/minecraft/class_7528;method_44391()Inamed getContentsHeightLnet/minecraft/client/gui/widget/ScrollableWidget;getContentsHeight()I
-
overflows
protected boolean overflows()Returns whether the contents overflow and needs a scrollbar.- Specified by:
overflowsin classScrollableWidget- Returns:
- whether the contents overflow and needs a scrollbar
- Mappings:
Namespace Name Mixin selector official fLeot;f()Zintermediary method_44392Lnet/minecraft/class_7528;method_44392()Znamed overflowsLnet/minecraft/client/gui/widget/ScrollableWidget;overflows()Z
-
getDeltaYPerScroll
protected double getDeltaYPerScroll()- Specified by:
getDeltaYPerScrollin classScrollableWidget- Mappings:
Namespace Name Mixin selector official gLeot;g()Dintermediary method_44393Lnet/minecraft/class_7528;method_44393()Dnamed getDeltaYPerScrollLnet/minecraft/client/gui/widget/ScrollableWidget;getDeltaYPerScroll()D
-
drawSelection
- Mappings:
Namespace Name Mixin selector official aLepp;a(Leop;IIII)Vintermediary method_44403Lnet/minecraft/class_7529;method_44403(Lnet/minecraft/class_332;IIII)Vnamed drawSelectionLnet/minecraft/client/gui/widget/EditBoxWidget;drawSelection(Lnet/minecraft/client/gui/DrawContext;IIII)V
-
onCursorChange
private void onCursorChange()- Mappings:
Namespace Name Mixin selector official wLepp;w()Vintermediary method_44407Lnet/minecraft/class_7529;method_44407()Vnamed onCursorChangeLnet/minecraft/client/gui/widget/EditBoxWidget;onCursorChange()V
-
getMaxLinesWithoutOverflow
private double getMaxLinesWithoutOverflow()Returns the maximum amount of lines the widget can hold without overflowing.- Returns:
- the maximum amount of lines the widget can hold without overflowing
- Mappings:
Namespace Name Mixin selector official xLepp;x()Dintermediary method_44408Lnet/minecraft/class_7529;method_44408()Dnamed getMaxLinesWithoutOverflowLnet/minecraft/client/gui/widget/EditBoxWidget;getMaxLinesWithoutOverflow()D
-
moveCursor
private void moveCursor(double mouseX, double mouseY) - Mappings:
Namespace Name Mixin selector official fLepp;f(DD)Vintermediary method_44404Lnet/minecraft/class_7529;method_44404(DD)Vnamed moveCursorLnet/minecraft/client/gui/widget/EditBoxWidget;moveCursor(DD)V
-