Aller au contenu
galdurdocs

GaldurSearchField

classclient uniquementdepuis 0.1.0

com.galdurstudio.galdurui.api.widget.GaldurSearchField

Pas encore traduit : texte d’origine en anglais.

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
PAQUETapi.widget
CÔTÉclient uniquement
HÉRITE DEAbstractWidget

Champs 1

MAX_LENGTH

static
public static final int MAX_LENGTH = 256

Maximum length of the typed text.

Constructeurs 1

GaldurSearchField

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

Prefer of().

PARAMÈTRES

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

Méthodes 3

of

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

PARAMÈTRES

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

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

preferredWidth

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

PARAMÈTRES

placeholderComponentthe hint text
minWidthintminimum width, in pixels

RENVOIEint — 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.

PARAMÈTRES

handlerSoundManager—
© 2026 Galdur Studio · galdurstudio.com · Discord · LGPL-3.0-onlyProduit non officiel. Non approuvé par Mojang ou Microsoft, ni associé à eux.