Skip to content

GaldurSearchField

classclient onlysince 0.1.0

com.galdurstudio.galdurui.api.widget.GaldurSearchField

Themed search field, usable in vanilla layouts.

Text editing itself (cursor, selection, copy and paste, Ctrl+A, text that scrolls when it overflows) is handled by a vanilla EditBox placed inside: Galdur UI draws the frame, the placeholder and the colours, and forwards mouse and keyboard to the edit box.

Like GaldurCheckbox, the widget does not own the text: it reads it every frame from a supplier and reports every keystroke. The text survives the widget being rebuilt, and code can change it at any time.

Example.java
String[] search = {""};column.addChild(GaldurSearchField.of(120, Component.literal("Search..."),        () -> search[0], text -> search[0] = text));
  • Placeholder: shown in a muted colour while the field is empty.
  • Disabled (active = false): muted text, no input.
  • Escape closes the screen, as everywhere in the game; the up and down arrows move to the neighbouring widget.

Height from the theme: spacing.field_height. The text is limited to 256 characters.

public class GaldurSearchField extends AbstractWidget
PACKAGEapi.widget
SIDEclient only
EXTENDSAbstractWidget

Fields 1

MAX_LENGTH

static
public static final int MAX_LENGTH = 256

Maximum length of the typed text.

Constructors 1

GaldurSearchField

protected
protected GaldurSearchField(int width, Component placeholder, Supplier<String> text, Consumer<String> onChange)

Prefer of().

PARAMETERS

widthinttotal width, frame included, in pixels
placeholderComponenthint text, shown while the field is empty
textSupplier<String>supplier of the current text, called every frame
onChangeConsumer<String>called with the new text on every change by the player

Methods 3

of

static
public static GaldurSearchField of(int width, Component placeholder, Supplier<String> text, Consumer<String> onChange)

PARAMETERS

widthinttotal width, frame included, in pixels
placeholderComponenthint text, shown while the field is empty
textSupplier<String>supplier of the current text, called every frame
onChangeConsumer<String>called with the new text on every change by the player

RETURNSGaldurSearchField — a search field at (0, 0), for a layout to place

preferredWidth

static
public static int preferredWidth(Component placeholder, int minWidth)

PARAMETERS

placeholderComponentthe hint text
minWidthintminimum width, in pixels

RETURNSint — the width that shows the placeholder in full, or minWidth if larger

playDownSound

public void playDownSound(SoundManager handler)

A text field does not play the button sound when clicked.

PARAMETERS

handlerSoundManager—
© 2026 Galdur Studio · galdurstudio.com · Discord · LGPL-3.0-onlyNot an official Minecraft product. Not approved by or associated with Mojang or Microsoft.