Class EditBoxWidget

All Implemented Interfaces:
Drawable, Element, Narratable, Navigable, Selectable, Widget

@Environment(CLIENT) public class EditBoxWidget extends ScrollableWidget
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
named net/minecraft/client/gui/widget/EditBoxWidget
intermediary net/minecraft/class_7529
official fim
  • Field Details

    • CURSOR_PADDING

      private static final int CURSOR_PADDING
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named CURSOR_PADDING Lnet/minecraft/client/gui/widget/EditBoxWidget;CURSOR_PADDING:I
      intermediary field_39502 Lnet/minecraft/class_7529;field_39502:I
      official a Lfim;a:I
    • CURSOR_COLOR

      private static final int CURSOR_COLOR
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named CURSOR_COLOR Lnet/minecraft/client/gui/widget/EditBoxWidget;CURSOR_COLOR:I
      intermediary field_39503 Lnet/minecraft/class_7529;field_39503:I
      official b Lfim;b:I
    • UNDERSCORE

      private static final String UNDERSCORE
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named UNDERSCORE Lnet/minecraft/client/gui/widget/EditBoxWidget;UNDERSCORE:Ljava/lang/String;
      intermediary field_39504 Lnet/minecraft/class_7529;field_39504:Ljava/lang/String;
      official c Lfim;c:Ljava/lang/String;
    • FOCUSED_BOX_TEXT_COLOR

      private static final int FOCUSED_BOX_TEXT_COLOR
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named FOCUSED_BOX_TEXT_COLOR Lnet/minecraft/client/gui/widget/EditBoxWidget;FOCUSED_BOX_TEXT_COLOR:I
      intermediary field_39505 Lnet/minecraft/class_7529;field_39505:I
      official d Lfim;d:I
    • UNFOCUSED_BOX_TEXT_COLOR

      private static final int UNFOCUSED_BOX_TEXT_COLOR
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named UNFOCUSED_BOX_TEXT_COLOR Lnet/minecraft/client/gui/widget/EditBoxWidget;UNFOCUSED_BOX_TEXT_COLOR:I
      intermediary field_39506 Lnet/minecraft/class_7529;field_39506:I
      official e Lfim;e:I
    • textRenderer

      private final TextRenderer textRenderer
      Mappings:
      Namespace Name Mixin selector
      named textRenderer Lnet/minecraft/client/gui/widget/EditBoxWidget;textRenderer:Lnet/minecraft/client/font/TextRenderer;
      intermediary field_39507 Lnet/minecraft/class_7529;field_39507:Lnet/minecraft/class_327;
      official m Lfim;m:Lfhf;
    • placeholder

      private final Text placeholder
      The placeholder text that gets rendered when the edit box is empty. This does not get returned from getText(); an empty string will be returned in such cases.
      Mappings:
      Namespace Name Mixin selector
      named placeholder Lnet/minecraft/client/gui/widget/EditBoxWidget;placeholder:Lnet/minecraft/text/Text;
      intermediary field_39508 Lnet/minecraft/class_7529;field_39508:Lnet/minecraft/class_2561;
      official n Lfim;n:Lwu;
    • editBox

      private final EditBox editBox
      Mappings:
      Namespace Name Mixin selector
      named editBox Lnet/minecraft/client/gui/widget/EditBoxWidget;editBox:Lnet/minecraft/client/gui/EditBox;
      intermediary field_39509 Lnet/minecraft/class_7529;field_39509:Lnet/minecraft/class_7530;
      official o Lfim;o:Lfip;
    • lastSwitchFocusTime

      private long lastSwitchFocusTime
      Mappings:
      Namespace Name Mixin selector
      named lastSwitchFocusTime Lnet/minecraft/client/gui/widget/EditBoxWidget;lastSwitchFocusTime:J
      intermediary field_45364 Lnet/minecraft/class_7529;field_45364:J
      official p Lfim;p:J
  • Constructor Details

    • EditBoxWidget

      public EditBoxWidget(TextRenderer textRenderer, int x, int y, int width, int height, Text placeholder, Text message)
      Mappings:
      Namespace Name Mixin selector
      named <init> Lnet/minecraft/client/gui/widget/EditBoxWidget;<init>(Lnet/minecraft/client/font/TextRenderer;IIIILnet/minecraft/text/Text;Lnet/minecraft/text/Text;)V
      intermediary <init> Lnet/minecraft/class_7529;<init>(Lnet/minecraft/class_327;IIIILnet/minecraft/class_2561;Lnet/minecraft/class_2561;)V
      official <init> Lfim;<init>(Lfhf;IIIILwu;Lwu;)V
  • Method Details

    • setMaxLength

      public void setMaxLength(int maxLength)
      Sets the maximum length of the edit box text in characters.

      If maxLength equals EditBox.UNLIMITED_LENGTH, the edit box does not have a length limit, and the widget does not show the current text length indicator.

      Throws:
      IllegalArgumentException - if maxLength is negative
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named setMaxLength Lnet/minecraft/client/gui/widget/EditBoxWidget;setMaxLength(I)V
      intermediary method_44402 Lnet/minecraft/class_7529;method_44402(I)V
      official a Lfim;a(I)V
    • setChangeListener

      public void setChangeListener(Consumer<String> changeListener)
      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 setChangeListener Lnet/minecraft/client/gui/widget/EditBoxWidget;setChangeListener(Ljava/util/function/Consumer;)V
      intermediary method_44401 Lnet/minecraft/class_7529;method_44401(Ljava/util/function/Consumer;)V
      official b Lfim;b(Ljava/util/function/Consumer;)V
    • setText

      public void setText(String text)
      Sets the text of the edit box and moves the cursor to the end of the edit box.
      Mappings:
      Namespace Name Mixin selector
      named setText Lnet/minecraft/client/gui/widget/EditBoxWidget;setText(Ljava/lang/String;)V
      intermediary method_44400 Lnet/minecraft/class_7529;method_44400(Ljava/lang/String;)V
      official a Lfim;a(Ljava/lang/String;)V
    • getText

      public String getText()
      Returns the current text of the edit box.
      Returns:
      the current text of the edit box
      Mappings:
      Namespace Name Mixin selector
      named getText Lnet/minecraft/client/gui/widget/EditBoxWidget;getText()Ljava/lang/String;
      intermediary method_44405 Lnet/minecraft/class_7529;method_44405()Ljava/lang/String;
      official j Lfim;j()Ljava/lang/String;
    • appendClickableNarrations

      public void appendClickableNarrations(NarrationMessageBuilder builder)
      Specified by:
      appendClickableNarrations in class ClickableWidget
      Mappings:
      Namespace Name Mixin selector
      named appendClickableNarrations Lnet/minecraft/client/gui/widget/ClickableWidget;appendClickableNarrations(Lnet/minecraft/client/gui/screen/narration/NarrationMessageBuilder;)V
      intermediary method_47399 Lnet/minecraft/class_339;method_47399(Lnet/minecraft/class_6382;)V
      official a Lfhs;a(Lflq;)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 in GLFW class.
      Specified by:
      mouseClicked in interface Element
      Overrides:
      mouseClicked in class ScrollableWidget
      Parameters:
      mouseX - the X coordinate of the mouse
      mouseY - the Y coordinate of the mouse
      button - the mouse button number
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named mouseClicked Lnet/minecraft/client/gui/Element;mouseClicked(DDI)Z
      intermediary method_25402 Lnet/minecraft/class_364;method_25402(DDI)Z
      official a Lfjq;a(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 in GLFW class.
      Specified by:
      mouseDragged in interface Element
      Overrides:
      mouseDragged in class ScrollableWidget
      Parameters:
      mouseX - the current X coordinate of the mouse
      mouseY - the current Y coordinate of the mouse
      button - the mouse button number
      deltaX - the difference of the current X with the previous X coordinate
      deltaY - the difference of the current Y with the previous Y coordinate
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named mouseDragged Lnet/minecraft/client/gui/Element;mouseDragged(DDIDD)Z
      intermediary method_25403 Lnet/minecraft/class_364;method_25403(DDIDD)Z
      official a Lfjq;a(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 in GLFW class.
      Specified by:
      keyPressed in interface Element
      Overrides:
      keyPressed in class ScrollableWidget
      Parameters:
      keyCode - the named key code of the event as described in the GLFW class
      scanCode - the unique/platform-specific scan code of the keyboard input
      modifiers - a GLFW bitfield describing the modifier keys that are held down (see GLFW Modifier key flags)
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named keyPressed Lnet/minecraft/client/gui/Element;keyPressed(III)Z
      intermediary method_25404 Lnet/minecraft/class_364;method_25404(III)Z
      official a Lfjq;a(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 in GLFW class.
      Parameters:
      chr - the captured character
      modifiers - a GLFW bitfield describing the modifier keys that are held down (see GLFW Modifier key flags)
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named charTyped Lnet/minecraft/client/gui/Element;charTyped(CI)Z
      intermediary method_25400 Lnet/minecraft/class_364;method_25400(CI)Z
      official a Lfjq;a(CI)Z
    • renderContents

      protected void renderContents(DrawContext context, int mouseX, int mouseY, float delta)
      Renders the scrolled contents. Subclasses must override this. The rendered contents may overflow; the caller should trim those using DrawContext.enableScissor(int, int, int, int).
      Specified by:
      renderContents in class ScrollableWidget
      Mappings:
      Namespace Name Mixin selector
      named renderContents Lnet/minecraft/client/gui/widget/ScrollableWidget;renderContents(Lnet/minecraft/client/gui/DrawContext;IIF)V
      intermediary method_44389 Lnet/minecraft/class_7528;method_44389(Lnet/minecraft/class_332;IIF)V
      official c Lfho;c(Lfhh;IIF)V
    • renderOverlay

      protected void renderOverlay(DrawContext context)
      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 super call is necessary to make sure the scrollbar renders when it should.

      Overrides:
      renderOverlay in class ScrollableWidget
      Mappings:
      Namespace Name Mixin selector
      named renderOverlay Lnet/minecraft/client/gui/widget/ScrollableWidget;renderOverlay(Lnet/minecraft/client/gui/DrawContext;)V
      intermediary method_44384 Lnet/minecraft/class_7528;method_44384(Lnet/minecraft/class_332;)V
      official a Lfho;a(Lfhh;)V
    • getContentsHeight

      public int getContentsHeight()
      Returns the total height of the contents.
      Specified by:
      getContentsHeight in class ScrollableWidget
      Returns:
      the total height of the contents
      Mappings:
      Namespace Name Mixin selector
      named getContentsHeight Lnet/minecraft/client/gui/widget/ScrollableWidget;getContentsHeight()I
      intermediary method_44391 Lnet/minecraft/class_7528;method_44391()I
      official h Lfho;h()I
    • overflows

      protected boolean overflows()
      Returns whether the contents overflow and needs a scrollbar.
      Overrides:
      overflows in class ScrollableWidget
      Returns:
      whether the contents overflow and needs a scrollbar
      Mappings:
      Namespace Name Mixin selector
      named overflows Lnet/minecraft/client/gui/widget/ScrollableWidget;overflows()Z
      intermediary method_44392 Lnet/minecraft/class_7528;method_44392()Z
      official e Lfho;e()Z
    • getDeltaYPerScroll

      protected double getDeltaYPerScroll()
      Specified by:
      getDeltaYPerScroll in class ScrollableWidget
      Mappings:
      Namespace Name Mixin selector
      named getDeltaYPerScroll Lnet/minecraft/client/gui/widget/ScrollableWidget;getDeltaYPerScroll()D
      intermediary method_44393 Lnet/minecraft/class_7528;method_44393()D
      official i Lfho;i()D
    • drawSelection

      private void drawSelection(DrawContext context, int left, int top, int right, int bottom)
      Mappings:
      Namespace Name Mixin selector
      named drawSelection Lnet/minecraft/client/gui/widget/EditBoxWidget;drawSelection(Lnet/minecraft/client/gui/DrawContext;IIII)V
      intermediary method_44403 Lnet/minecraft/class_7529;method_44403(Lnet/minecraft/class_332;IIII)V
      official b Lfim;b(Lfhh;IIII)V
    • onCursorChange

      private void onCursorChange()
      Mappings:
      Namespace Name Mixin selector
      named onCursorChange Lnet/minecraft/client/gui/widget/EditBoxWidget;onCursorChange()V
      intermediary method_44407 Lnet/minecraft/class_7529;method_44407()V
      official k Lfim;k()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
      named getMaxLinesWithoutOverflow Lnet/minecraft/client/gui/widget/EditBoxWidget;getMaxLinesWithoutOverflow()D
      intermediary method_44408 Lnet/minecraft/class_7529;method_44408()D
      official l Lfim;l()D
    • moveCursor

      private void moveCursor(double mouseX, double mouseY)
      Mappings:
      Namespace Name Mixin selector
      named moveCursor Lnet/minecraft/client/gui/widget/EditBoxWidget;moveCursor(DD)V
      intermediary method_44404 Lnet/minecraft/class_7529;method_44404(DD)V
      official e Lfim;e(DD)V
    • setFocused

      public void setFocused(boolean focused)
      Specified by:
      setFocused in interface Element
      Overrides:
      setFocused in class ClickableWidget
      Mappings:
      Namespace Name Mixin selector
      named setFocused Lnet/minecraft/client/gui/Element;setFocused(Z)V
      intermediary method_25365 Lnet/minecraft/class_364;method_25365(Z)V
      official a Lfjq;a(Z)V