Class TextField
java.lang.Object
dev.myriadclient.api.ui.widget.Widget
dev.myriadclient.api.ui.widget.TextField
Single-line text input.
onChange fires on every edit, onSubmit on Enter. While unfocused it shows
getter's value; clicking it (or Enter, or / for the first field in a window) starts editing a copy of
that value, and the field holds keyboard focus until Enter, Escape or a click elsewhere. While focused it takes every
key, so the UI's shortcuts don't fire. Ctrl+Left and Ctrl+Backspace go by words, Ctrl+A/C/V (Cmd on a Mac) select
all, copy and paste; right-click empties it.
content.add(new TextField(() -> filter).onChange(s -> filter = s).search().placeholder("Filter…"));
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Enter/Space on the selected widget.booleancharTyped(char chr, int mods) A character typed while this widget is focused.booleanhasFocus()Whether the keyboard is typing here.A glyph at the left of the field: a search box's magnifier.booleanWhether the keyboard selection (j/k, arrows) can land on this widget.booleankeyPressed(int key, int scancode, int mods) A key pressed while this widget is focused:keyis its position (anInputConstants.KEY_*value),scancodewhat it types on the player's layout (asKeyEvent);modifiersareInputConstants.MOD_*bits.protected floatCompute height forwidthand position children.floatThe narrowest this is still usable at, for a row deciding whether to shrink it or wrap (HBox), or -1 if it has no opinion: a row then keeps a fixed child at its width and gives a shared one a small default.booleanmouseClicked(float mx, float my, int button) A mouse press at (mouseX,mouseY);buttonis a GLFW button (InputConstants.MOUSE_BUTTON_*).protected voidonBlur()Called when this widget loses keyboard focus.Called with the whole text after every edit while typing (including emptying it).Called with the text when Enter is pressed, before the field lets go of the keyboard.placeholder(String placeholder) Dim text shown while the field is empty and not being edited.voidLets go of the keyboard, as Escape does.voidDraws the widget within its box (Widget.x,Widget.y,Widget.width,Widget.height), with the mouse in the same coordinates (far off screen while the pointer is outside the panel or a scroll view's viewport).voidFocuses the field programmatically (e.g.search()A search box: the magnifier at its left, and a cross at its right that empties it once it holds something.voidReplaces what's being typed withs, the cursor at its end, and callsonChange.text()What's typed while it's being edited, otherwisegetter's value.Methods inherited from class Widget
activateSecondary, adjust, attachChild, badgeLine, blur, collectNavigable, focus, height, isFocused, isHovered, isVisible, layout, mouseDragged, mouseReleased, mouseScrolled, navHeight, offerTooltip, press, theme, tooltip, visible, width, x, y
-
Constructor Details
-
TextField
-
-
Method Details
-
onChange
-
onSubmit
-
placeholder
-
icon
-
search
A search box: the magnifier at its left, and a cross at its right that empties it once it holds something. Returns this field. -
text
What's typed while it's being edited, otherwisegetter's value. -
hasFocus
@AvailableSince("1.4") public boolean hasFocus()Whether the keyboard is typing here. -
releaseFocus
@AvailableSince("1.4") public void releaseFocus()Lets go of the keyboard, as Escape does. -
requestFocus
public void requestFocus()Focuses the field programmatically (e.g. a launcher's search box). -
setText
Replaces what's being typed withs, the cursor at its end, and callsonChange. While the field isn't focused it showsgetter's value regardless. -
measure
-
minWidth
-
render
Description copied from class:WidgetDraws the widget within its box (Widget.x,Widget.y,Widget.width,Widget.height), with the mouse in the same coordinates (far off screen while the pointer is outside the panel or a scroll view's viewport). Called every frame afterWidget.layout(Canvas, float, float, float), only while visible. -
mouseClicked
public boolean mouseClicked(float mx, float my, int button) Description copied from class:WidgetA mouse press at (mouseX,mouseY);buttonis a GLFW button (InputConstants.MOUSE_BUTTON_*). Presses go to every visible widget in turn until one returns true, so checkWidget.isHovered(float, float)first. Returning true makes this widget receive the drags and the release.- Overrides:
mouseClickedin classWidget
-
activate
-
onBlur
-
keyPressed
public boolean keyPressed(int key, int scancode, int mods) Description copied from class:WidgetA key pressed while this widget is focused:keyis its position (anInputConstants.KEY_*value),scancodewhat it types on the player's layout (asKeyEvent);modifiersareInputConstants.MOD_*bits.- Overrides:
keyPressedin classWidget
-
charTyped
-