ListHandle
classclient uniquementdepuis 0.1.0com.galdurstudio.galdurui.api.window.ListHandle
Pas encore traduit : texte d’origine en anglais.
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.
MEMBRES · 15
Méthodes 15
addLine
Adds a line at the end of the list.
PARAMÈTRES
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.
PARAMÈTRES
clearLines
Removes all lines, and the selection with them.
getLines
RENVOIEList<Component> — the lines, read-only; the view follows changes to the list
getSelected
RENVOIEint — 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.
PARAMÈTRES
-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.
PARAMÈTRES
getScroll
RENVOIEdouble — 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.
PARAMÈTRES
setEnabled
de ElementHandleEnables or disables the element. No effect if it is already in that state.
PARAMÈTRES
false to disable itisEnabled
de ElementHandleRENVOIEboolean — true if the element is enabled (the default)
setVisible
de ElementHandleShows or hides the element. Hidden, it frees its space in the window. No effect if it is already in that state.
PARAMÈTRES
false to hide itisVisible
de ElementHandleRENVOIEboolean — true if the element is shown (the default)
setTooltip
de ElementHandleSets the text shown when the element is hovered.
PARAMÈTRES
null to remove itgetTooltip
de ElementHandleRENVOIEComponent — the tooltip text, or null if none