Class EditBox

All Implemented Interfaces:
GuiEventListener, Widget, NarratableEntry, NarrationSupplier

public class EditBox extends AbstractWidget implements Widget, GuiEventListener
  • Field Details

    • BACKWARDS

      public static final int BACKWARDS
      See Also:
      Constant Field Values
    • FORWARDS

      public static final int FORWARDS
      See Also:
      Constant Field Values
    • CURSOR_INSERT_WIDTH

      private static final int CURSOR_INSERT_WIDTH
      See Also:
      Constant Field Values
    • CURSOR_INSERT_COLOR

      private static final int CURSOR_INSERT_COLOR
      See Also:
      Constant Field Values
    • CURSOR_APPEND_CHARACTER

      private static final String CURSOR_APPEND_CHARACTER
      See Also:
      Constant Field Values
    • DEFAULT_TEXT_COLOR

      public static final int DEFAULT_TEXT_COLOR
      See Also:
      Constant Field Values
    • BORDER_COLOR_FOCUSED

      private static final int BORDER_COLOR_FOCUSED
      See Also:
      Constant Field Values
    • BORDER_COLOR

      private static final int BORDER_COLOR
      See Also:
      Constant Field Values
    • BACKGROUND_COLOR

      private static final int BACKGROUND_COLOR
      See Also:
      Constant Field Values
    • font

      private final Font font
    • value

      private String value
    • maxLength

      private int maxLength
    • frame

      private int frame
    • bordered

      private boolean bordered
    • canLoseFocus

      private boolean canLoseFocus
    • isEditable

      private boolean isEditable
    • shiftPressed

      private boolean shiftPressed
    • displayPos

      private int displayPos
    • cursorPos

      private int cursorPos
    • highlightPos

      private int highlightPos
    • textColor

      private int textColor
    • textColorUneditable

      private int textColorUneditable
    • suggestion

      @Nullable private String suggestion
    • responder

      @Nullable private Consumer<String> responder
    • filter

      private Predicate<String> filter
    • formatter

      private BiFunction<String,​Integer,​FormattedCharSequence> formatter
  • Constructor Details

    • EditBox

      public EditBox(Font p_94114_, int p_94115_, int p_94116_, int p_94117_, int p_94118_, Component p_94119_)
    • EditBox

      public EditBox(Font p_94106_, int p_94107_, int p_94108_, int p_94109_, int p_94110_, @Nullable EditBox p_94111_, Component p_94112_)
  • Method Details

    • setResponder

      public void setResponder(Consumer<String> p_94152_)
    • setFormatter

      public void setFormatter(BiFunction<String,​Integer,​FormattedCharSequence> p_94150_)
    • tick

      public void tick()
    • createNarrationMessage

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

      public void setValue(String p_94145_)
    • getValue

      public String getValue()
    • getHighlighted

      public String getHighlighted()
    • setFilter

      public void setFilter(Predicate<String> p_94154_)
    • insertText

      public void insertText(String p_94165_)
    • onValueChange

      private void onValueChange(String p_94175_)
    • deleteText

      private void deleteText(int p_94218_)
    • deleteWords

      public void deleteWords(int p_94177_)
    • deleteChars

      public void deleteChars(int p_94181_)
    • getWordPosition

      public int getWordPosition(int p_94185_)
    • getWordPosition

      private int getWordPosition(int p_94129_, int p_94130_)
    • getWordPosition

      private int getWordPosition(int p_94141_, int p_94142_, boolean p_94143_)
    • moveCursor

      public void moveCursor(int p_94189_)
    • getCursorPos

      private int getCursorPos(int p_94221_)
    • moveCursorTo

      public void moveCursorTo(int p_94193_)
    • setCursorPosition

      public void setCursorPosition(int p_94197_)
    • moveCursorToStart

      public void moveCursorToStart()
    • moveCursorToEnd

      public void moveCursorToEnd()
    • keyPressed

      public boolean keyPressed(int p_94132_, int p_94133_, int p_94134_)
      Specified by:
      keyPressed in interface GuiEventListener
    • canConsumeInput

      public boolean canConsumeInput()
    • charTyped

      public boolean charTyped(char p_94122_, int p_94123_)
      Specified by:
      charTyped in interface GuiEventListener
    • mouseClicked

      public boolean mouseClicked(double p_94125_, double p_94126_, int p_94127_)
      Specified by:
      mouseClicked in interface GuiEventListener
      Overrides:
      mouseClicked in class AbstractWidget
    • setFocus

      public void setFocus(boolean p_94179_)
    • renderButton

      public void renderButton(PoseStack p_94160_, int p_94161_, int p_94162_, float p_94163_)
      Overrides:
      renderButton in class AbstractWidget
    • renderHighlight

      private void renderHighlight(int p_94136_, int p_94137_, int p_94138_, int p_94139_)
    • setMaxLength

      public void setMaxLength(int p_94200_)
    • getMaxLength

      private int getMaxLength()
    • getCursorPosition

      public int getCursorPosition()
    • isBordered

      private boolean isBordered()
    • setBordered

      public void setBordered(boolean p_94183_)
    • setTextColor

      public void setTextColor(int p_94203_)
    • setTextColorUneditable

      public void setTextColorUneditable(int p_94206_)
    • changeFocus

      public boolean changeFocus(boolean p_94172_)
      Specified by:
      changeFocus in interface GuiEventListener
      Overrides:
      changeFocus in class AbstractWidget
    • isMouseOver

      public boolean isMouseOver(double p_94157_, double p_94158_)
      Specified by:
      isMouseOver in interface GuiEventListener
      Overrides:
      isMouseOver in class AbstractWidget
    • onFocusedChanged

      protected void onFocusedChanged(boolean p_94170_)
      Overrides:
      onFocusedChanged in class AbstractWidget
    • isEditable

      private boolean isEditable()
    • setEditable

      public void setEditable(boolean p_94187_)
    • getInnerWidth

      public int getInnerWidth()
    • setHighlightPos

      public void setHighlightPos(int p_94209_)
    • setCanLoseFocus

      public void setCanLoseFocus(boolean p_94191_)
    • isVisible

      public boolean isVisible()
    • setVisible

      public void setVisible(boolean p_94195_)
    • setSuggestion

      public void setSuggestion(@Nullable String p_94168_)
    • getScreenX

      public int getScreenX(int p_94212_)
    • setX

      public void setX(int p_94215_)
    • updateNarration

      public void updateNarration(NarrationElementOutput p_169009_)
      Specified by:
      updateNarration in interface NarrationSupplier