Aller au contenu
galdurdocs

GaldurScrollList

classclient uniquementdepuis 0.1.0

com.galdurstudio.galdurui.api.widget.GaldurScrollList

Pas encore traduit : texte d’origine en anglais.

Themed scrolling list of text lines, usable in vanilla layouts. The player selects a line with a click, or with the up and down arrows.

Like GaldurCheckbox, the widget keeps neither the lines nor the selection: it reads them every frame from suppliers and reports the changes the player asks for. The lines can change at any time without rebuilding the widget. Only the scroll position lives in the widget; onScroll() lets you keep it elsewhere when the widget is rebuilt (resize).

Example.java
List<Component> ores = List.of(Component.literal("Iron"), Component.literal("Gold"));int[] choice = {-1};column.addChild(GaldurScrollList.of(120, 5, () -> ores,        () -> choice[0], index -> choice[0] = index));
  • Mouse wheel: scrolls one line per notch.
  • Scrollbar: shown only when the lines do not fit; it can be grabbed and dragged.
  • Keyboard: up and down arrows change the selection; the list scrolls to keep the selected line visible.
  • Disabled (active = false): muted text, no click, selection or scrolling.

A line that is too long is clipped at the list edge (see GaldurRender.drawClipped). Sizes from the theme: spacing.list_row_height and spacing.scrollbar_width.

public class GaldurScrollList extends AbstractWidget
PAQUETapi.widget
CÔTÉclient uniquement
HÉRITE DEAbstractWidget

Constructeurs 1

GaldurScrollList

protected
protected GaldurScrollList(int width, int visibleRows, Supplier<List<Component>> lines, IntSupplier selected, IntConsumer onSelect)

Prefer of().

PARAMÈTRES

widthinttotal width, frame and scrollbar included, in pixels
visibleRowsintnumber of lines visible at once (at least 1)
linesSupplier<List<Component>>supplier of the lines, called every frame
selectedIntSuppliersupplier of the selected line index, or -1 for none
onSelectIntConsumercalled with the index of the line the player selects

Méthodes 7

of

static
public static GaldurScrollList of(int width, int visibleRows, Supplier<List<Component>> lines, IntSupplier selected, IntConsumer onSelect)

PARAMÈTRES

widthinttotal width, frame and scrollbar included, in pixels
visibleRowsintnumber of lines visible at once (at least 1); sets the height
linesSupplier<List<Component>>supplier of the lines, called every frame
selectedIntSuppliersupplier of the selected line index, or -1 for none
onSelectIntConsumercalled with the index of the line the player selects

RENVOIEGaldurScrollList — a scrolling list at (0, 0), for a layout to place

preferredWidth

static
public static int preferredWidth(List<Component> lines, int minWidth)

PARAMÈTRES

linesList<Component>the lines to show
minWidthintminimum width, in pixels

RENVOIEint — the width that shows the longest given line in full, scrollbar included, or minWidth if larger

onScroll

public GaldurScrollList onScroll(DoubleConsumer onScroll)

Sets the action called when the scroll offset changes, by the player or by code. Only one action is kept.

PARAMÈTRES

onScrollDoubleConsumerreceives the new offset, in pixels from the top of the content

RENVOIEGaldurScrollList — this list, for chaining

getScroll

public double getScroll()

RENVOIEdouble — the scroll offset, in pixels from the top of the content

setScroll

public void setScroll(double scroll)

Scrolls the list, clamped between the top and the bottom of the content.

PARAMÈTRES

scrolldoublewanted offset, in pixels from the top of the content

scrollToLine

public void scrollToLine(int index)

Scrolls just enough for line index to be fully visible.

PARAMÈTRES

indexintthe line index; no effect when outside the list

playDownSound

public void playDownSound(SoundManager handler)

A list does not play the button sound when a line is 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.