Class TextField

java.lang.Object
me.hackware.api.gui.TextField

public final class TextField extends Object
A self-contained rounded text input. Owns its own editing state (text, caret, selection, horizontal scroll) and input handling, independent of the host screen's activeInput machinery — the Macros tab forwards key/char events straight to the focused field.

Editing is committed live to getText(); the host reads it and persists via the manager. An optional onCommit runs on Enter / blur.

  • Constructor Details

    • TextField

      public TextField()
  • Method Details

    • onCommit

      public TextField onCommit(Runnable r)
    • onPasteMultiline

      public TextField onPasteMultiline(Consumer<String> handler)
      Routes pastes containing newlines to the host instead of flattening them to spaces — the host decides how the extra lines materialise.
    • hudStyle

      public TextField hudStyle()
      Switches to the HUD-properties-window text box look: translucent black body, square corners, a 1px frame (accent while editing, tertiary idle), secondary idle / primary editing content colours.
    • bare

      public TextField bare()
      Bare mode: no box or frame at all — just text, selection and caret. For fields living inside a container that provides the chrome (list rows).
    • padRight

      public TextField padRight(int px)
      Reserves px logical pixels inside the right edge — content scrolls and clips before them, so the host can draw an inline adornment (e.g. a status icon) there without text running underneath.
    • highlighter

      public TextField highlighter(BiFunction<String,Integer,List<TextSpan>> h)
      Renders content through coloured spans (syntax highlighting). Called with (text, plainColor) each frame; plain runs should use the given colour.
    • labeled

      public TextField labeled(String label)
      Switches to the nextui outlined InputField look (new-components): a transparent body with a rounded border, accent border + 1px ring and accent caret when focused, and this floating label — centred while empty, floated onto the border line once focused or filled.
    • getText

      public String getText()
    • setText

      public void setText(String value)
    • insertText

      public void insertText(String s)
      Inserts text at the caret, replacing any selection.
    • getCursor

      public int getCursor()
      Current caret index.
    • replaceRange

      public void replaceRange(int start, int end, String replacement)
      Replaces [start, end) with replacement; caret lands after it.
    • undo

      public boolean undo()
    • redo

      public boolean redo()
    • isFocused

      public boolean isFocused()
    • focus

      public void focus()
    • blur

      public void blur()
    • render

      public void render(UiContext ui, int x, int y, int w, int h, String placeholder)
    • render

      public void render(UiContext ui, int x, int y, int w, int h, String placeholder, float fade)
      render(me.hackware.api.gui.UiContext, int, int, int, int, java.lang.String) variant that multiplies every drawn colour by fade (0..1), so a host can fade the whole field in/out with an animating popover. applyAlpha(c, 1f) is the identity, so the plain overload is unchanged.
    • mouseClicked

      public boolean mouseClicked(net.minecraft.client.gui.Font font, double mx, double my)
      Returns true if the click landed in the field (and focuses it). Repeated clicks expand the selection like the HUD editor fields: click → caret, double-click → word, triple-click → all; dragging from any click sweeps a selection using the click's selection as the anchor.
    • mouseDragged

      public boolean mouseDragged(net.minecraft.client.gui.Font font, double mx)
      Sweeps the selection while dragging from a press inside the field.
    • mouseReleased

      public void mouseReleased()
    • charTyped

      public boolean charTyped(int codepoint)
    • keyPressed

      public boolean keyPressed(net.minecraft.client.input.KeyEvent event)