Package me.hackware.api.gui
Class TextField
java.lang.Object
me.hackware.api.gui.TextField
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbare()Bare mode: no box or frame at all — just text, selection and caret.voidblur()booleancharTyped(int codepoint) voidfocus()intCurrent caret index.getText()Renders content through coloured spans (syntax highlighting).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.voidinsertText(String s) Inserts text at the caret, replacing any selection.booleanbooleankeyPressed(net.minecraft.client.input.KeyEvent event) 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.booleanmouseClicked(net.minecraft.client.gui.Font font, double mx, double my) Returns true if the click landed in the field (and focuses it).booleanmouseDragged(net.minecraft.client.gui.Font font, double mx) Sweeps the selection while dragging from a press inside the field.voidonPasteMultiline(Consumer<String> handler) Routes pastes containing newlines to the host instead of flattening them to spaces — the host decides how the extra lines materialise.padRight(int px) Reservespxlogical pixels inside the right edge — content scrolls and clips before them, so the host can draw an inline adornment (e.g.booleanredo()voidvoidrender(me.hackware.api.gui.UiContext, int, int, int, int, java.lang.String)variant that multiplies every drawn colour byfade(0..1), so a host can fade the whole field in/out with an animating popover.voidreplaceRange(int start, int end, String replacement) Replaces[start, end)withreplacement; caret lands after it.voidbooleanundo()
-
Constructor Details
-
TextField
public TextField()
-
-
Method Details
-
onCommit
-
onPasteMultiline
Routes pastes containing newlines to the host instead of flattening them to spaces — the host decides how the extra lines materialise. -
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
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
Reservespxlogical 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
Renders content through coloured spans (syntax highlighting). Called with (text, plainColor) each frame; plain runs should use the given colour. -
labeled
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
-
setText
-
insertText
Inserts text at the caret, replacing any selection. -
getCursor
public int getCursor()Current caret index. -
replaceRange
Replaces[start, end)withreplacement; 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
-
render
render(me.hackware.api.gui.UiContext, int, int, int, int, java.lang.String)variant that multiplies every drawn colour byfade(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)
-