ListHandle
classclient onlysince 0.1.0com.galdurstudio.galdurui.api.window.ListHandle
Handle to a scrolling list of a GaldurWindow: its lines, the selected line and the
scroll position.
Returned by GaldurWindow.addList(...). As with CheckboxHandle, the state
lives here, not in the shown widget: it survives resizes, and the lines can change at any time,
even while the window is open, without rebuilding the screen.
ListHandle ores = window.addList(5);ores.addLine(Component.literal("Iron"));ores.addLine(Component.literal("Gold"));ores.onSelect(index -> System.out.println("Chosen: " + index));The list width is computed when the screen is built, from the longest line. A longer line
added later is clipped at the edge until the next rebuild (resize, or an element added to the
window). Like any ElementHandle, the list can be disabled, hidden or given a
tooltip.
Call on the client thread.
MEMBERS · 15
Methods 15
addLine
Adds a line at the end of the list.
PARAMETERS
setLines
Replaces all lines, for instance to show a search result. The selection is cleared, since
its index would now point at another line; if there was one, onSelect()
is called with -1.
PARAMETERS
clearLines
Removes all lines, and the selection with them.
getLines
RETURNSList<Component> — the lines, read-only; the view follows changes to the list
getSelected
RETURNSint — the index of the selected line, or -1 if none
setSelected
Selects a line. When the value really changes, the action given to
onSelect() is called, whether the change comes from the player or from
code.
PARAMETERS
-1 for none; an index outside the list counts as
-1onSelect
Sets the action called when the selection changes. Only one action is kept: a new call
replaces the previous one. It receives the line index, or -1.
PARAMETERS
getScroll
RETURNSdouble — the scroll offset, in pixels from the top of the content
setScroll
Remembers the scroll offset, to restore it when the screen is rebuilt. Called by the shown widget; a mod usually does not need it.
PARAMETERS
setEnabled
from ElementHandleEnables or disables the element. No effect if it is already in that state.
PARAMETERS
false to disable itisEnabled
from ElementHandleRETURNSboolean — true if the element is enabled (the default)
setVisible
from ElementHandleShows or hides the element. Hidden, it frees its space in the window. No effect if it is already in that state.
PARAMETERS
false to hide itisVisible
from ElementHandleRETURNSboolean — true if the element is shown (the default)
setTooltip
from ElementHandleSets the text shown when the element is hovered.
PARAMETERS
null to remove itgetTooltip
from ElementHandleRETURNSComponent — the tooltip text, or null if none