Class EditBox

java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
net.minecraft.client.gui.components.EditBox
All Implemented Interfaces:
GuiEventListener, Renderable, TabOrderedElement, LayoutElement, NarratableEntry, NarrationSupplier

public class EditBox extends AbstractWidget
  • Field Details

    • SPRITES

      private static final WidgetSprites SPRITES
    • BACKWARDS

      public static final int BACKWARDS
      See Also:
    • FORWARDS

      public static final int FORWARDS
      See Also:
    • DEFAULT_TEXT_COLOR

      public static final int DEFAULT_TEXT_COLOR
      See Also:
    • DEFAULT_HINT_STYLE

      public static final Style DEFAULT_HINT_STYLE
    • SEARCH_HINT_STYLE

      public static final Style SEARCH_HINT_STYLE
    • font

      private final Font font
    • value

      private String value
    • maxLength

      private int maxLength
    • bordered

      private boolean bordered
    • canLoseFocus

      private boolean canLoseFocus
    • isEditable

      private boolean isEditable
    • centered

      private boolean centered
    • textShadow

      private boolean textShadow
    • invertHighlightedTextColor

      private boolean invertHighlightedTextColor
    • displayPos

      private int displayPos
    • cursorPos

      private int cursorPos
    • highlightPos

      private int highlightPos
    • textColor

      private int textColor
    • textColorUneditable

      private int textColorUneditable
    • suggestion

      private @Nullable String suggestion
    • responder

      private @Nullable Consumer<String> responder
    • formatters

      private final List<EditBox.TextFormatter> formatters
    • hint

      private @Nullable Component hint
    • preeditOverlay

      private @Nullable IMEPreeditOverlay preeditOverlay
    • focusedTime

      private long focusedTime
    • textX

      private int textX
    • textY

      private int textY
    • filter

      private Predicate<String> filter
  • Constructor Details

    • EditBox

      public EditBox(Font font, int width, int height, Component narration)
    • EditBox

      public EditBox(Font font, int x, int y, int width, int height, Component narration)
    • EditBox

      public EditBox(Font font, int x, int y, int width, int height, @Nullable EditBox oldBox, Component narration)
  • Method Details

    • setResponder

      public void setResponder(Consumer<String> responder)
    • addFormatter

      public void addFormatter(EditBox.TextFormatter formatter)
    • createNarrationMessage

      protected MutableComponent createNarrationMessage()
      Overrides:
      createNarrationMessage in class AbstractWidget
    • setValue

      public void setValue(String value)
    • getValue

      public String getValue()
    • getHighlighted

      public String getHighlighted()
    • setX

      public void setX(int x)
      Specified by:
      setX in interface LayoutElement
      Overrides:
      setX in class AbstractWidget
    • setY

      public void setY(int y)
      Specified by:
      setY in interface LayoutElement
      Overrides:
      setY in class AbstractWidget
    • setFilter

      public void setFilter(Predicate<String> filter)
      Sets a filter on the edit box that will only allow strings that pass the given predicate to be inserted.
    • insertText

      public void insertText(String input)
    • onValueChange

      private void onValueChange(String value)
    • deleteText

      private void deleteText(int dir, boolean wholeWord)
    • deleteWords

      public void deleteWords(int dir)
    • deleteChars

      public void deleteChars(int dir)
    • deleteCharsToPos

      public void deleteCharsToPos(int pos)
    • getWordPosition

      public int getWordPosition(int dir)
    • getWordPosition

      private int getWordPosition(int dir, int from)
    • getWordPosition

      private int getWordPosition(int dir, int from, boolean stripSpaces)
    • moveCursor

      public void moveCursor(int dir, boolean hasShiftDown)
    • getCursorPos

      private int getCursorPos(int dir)
    • moveCursorTo

      public void moveCursorTo(int dir, boolean extendSelection)
    • setCursorPosition

      public void setCursorPosition(int pos)
    • moveCursorToStart

      public void moveCursorToStart(boolean hasShiftDown)
    • moveCursorToEnd

      public void moveCursorToEnd(boolean hasShiftDown)
    • keyPressed

      public boolean keyPressed(KeyEvent event)
    • canConsumeInput

      public boolean canConsumeInput()
    • charTyped

      public boolean charTyped(CharacterEvent event)
    • preeditUpdated

      public boolean preeditUpdated(@Nullable PreeditEvent event)
    • findClickedPositionInText

      private int findClickedPositionInText(MouseButtonEvent event)
    • selectWord

      private void selectWord(MouseButtonEvent event)
    • onClick

      public void onClick(MouseButtonEvent event, boolean doubleClick)
      Overrides:
      onClick in class AbstractWidget
    • onDrag

      protected void onDrag(MouseButtonEvent event, double dx, double dy)
      Overrides:
      onDrag in class AbstractWidget
    • playDownSound

      public void playDownSound(SoundManager soundManager)
      Overrides:
      playDownSound in class AbstractWidget
    • extractWidgetRenderState

      public void extractWidgetRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a)
      Specified by:
      extractWidgetRenderState in class AbstractWidget
    • applyFormat

      private FormattedCharSequence applyFormat(String text, int offset)
    • updateTextPosition

      private void updateTextPosition()
    • setMaxLength

      public void setMaxLength(int maxLength)
    • getMaxLength

      private int getMaxLength()
    • getCursorPosition

      public int getCursorPosition()
    • isBordered

      public boolean isBordered()
    • setBordered

      public void setBordered(boolean bordered)
    • setTextColor

      public void setTextColor(int textColor)
    • setTextColorUneditable

      public void setTextColorUneditable(int textColorUneditable)
    • setFocused

      public void setFocused(boolean focused)
      Specified by:
      setFocused in interface GuiEventListener
      Overrides:
      setFocused in class AbstractWidget
    • isEditable

      private boolean isEditable()
    • setEditable

      public void setEditable(boolean isEditable)
    • isCentered

      private boolean isCentered()
    • setCentered

      public void setCentered(boolean centered)
    • setTextShadow

      public void setTextShadow(boolean textShadow)
    • setInvertHighlightedTextColor

      public void setInvertHighlightedTextColor(boolean invertHighlightedTextColor)
    • getInnerWidth

      public int getInnerWidth()
    • setHighlightPos

      public void setHighlightPos(int pos)
    • scrollTo

      private void scrollTo(int pos)
    • setCanLoseFocus

      public void setCanLoseFocus(boolean canLoseFocus)
    • isVisible

      public boolean isVisible()
    • setVisible

      public void setVisible(boolean visible)
    • setSuggestion

      public void setSuggestion(@Nullable String suggestion)
    • getScreenX

      public int getScreenX(int charIndex)
    • updateWidgetNarration

      public void updateWidgetNarration(NarrationElementOutput output)
      Specified by:
      updateWidgetNarration in class AbstractWidget
    • setHint

      public void setHint(Component hint)
    • getTextShadow

      public boolean getTextShadow()