GaldurIconButton
classclient onlysince 0.1.0com.galdurstudio.galdurui.api.widget.GaldurIconButton
Square button without text that shows an icon: a GUI sprite or an item.
Same background, states and behaviour as GaldurButton; only the contents change. The
label is not drawn but is required: it is the tooltip and the narrated
text.
row.addChild(GaldurIconButton.ofItem(new ItemStack(Items.HOPPER), Component.literal("Sort"), button -> sort()));row.addChild(GaldurIconButton.of(ResourceLocation.fromNamespaceAndPath("mymod", "icon/sort"), Component.literal("Sort"), button -> sort()));A sprite is drawn 16 × 16, tinted text (text_muted when disabled): provide it
in grayscale. An item is drawn as in an inventory and veiled when disabled. The side is
spacing.button_height, to line up with text buttons in the same row.
MEMBERS · 9
Constructors 1
GaldurIconButton
protectedPARAMETERS
null to show itemMethods 8
of
staticPARAMETERS
RETURNSGaldurIconButton — a button showing a grayscale GUI sprite, at (0, 0)
ofItem
staticPARAMETERS
RETURNSGaldurIconButton — a button showing an item (copied), at (0, 0)
getPreferredWidth
RETURNSint — the button side: an icon button does not widen to its label
withSprites
from GaldurButtonReplaces the sprites. They are tinted like the default ones, so provide them in grayscale: white takes the exact theme colour.
PARAMETERS
RETURNSGaldurButton — this button
Draws the button contents over its background: by default the centred label, in
text or text_muted when disabled. Override it to show something else while
keeping the states and behaviour (see GaldurIconButton).
PARAMETERS
onRelease
from GaldurButtonFires only if the press started on this button and ends on it: dragging away cancels, as everywhere in the game.
PARAMETERS
isHeld
from GaldurButtonRETURNSboolean — true while the mouse button is held down on this button
clearHeld
from GaldurButtonForgets the pressed state now. Rarely needed: a press whose release was not seen is forgotten
on the first frame where the mouse button is up. Useful for a Screen that keeps its
buttons across init() calls and wants a clean state before the next frame.