GaldurButton
classclient onlysince 0.1.0com.galdurstudio.galdurui.api.widget.GaldurButton
Themed button with a centred label.
Four states, each with a grayscale 9-slice sprite tinted by a theme colour: idle
(accent), hovered or keyboard-focused (accent_hover, faded in), pressed
(accent_pressed) and disabled (surface, label in text_muted). Disable it
with the inherited active field.
layout.addChild(GaldurButton.of(Component.literal("Confirm"), button -> confirm()));Colours are read from the theme every frame. The size is fixed at construction:
of() sizes the button from its label and the theme spacings.
Constructors 1
GaldurButton
Creates a button with a given position and size; of() sizes it from
its label instead.
PARAMETERS
Methods 7
of
staticPARAMETERS
RETURNSGaldurButton — a button sized from its label, at (0, 0) for a layout to place
withSprites
Replaces the sprites. They are tinted like the default ones, so provide them in grayscale: white takes the exact theme colour.
PARAMETERS
RETURNSGaldurButton — this button
getPreferredWidth
RETURNSint — the smallest width that shows the whole label
renderContent
protectedDraws 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
Fires only if the press started on this button and ends on it: dragging away cancels, as everywhere in the game.
PARAMETERS
isHeld
RETURNSboolean — true while the mouse button is held down on this button
clearHeld
Forgets 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.
Nested types 1
OnPress
Action run when the button is activated, by mouse or keyboard.