Module technology.sola.engine
Class ButtonGuiElement
java.lang.Object
technology.sola.engine.graphics.gui.GuiElement<Style,ElementType>
technology.sola.engine.graphics.gui.elements.input.BaseInputGuiElement<BaseStyles,ButtonGuiElement>
technology.sola.engine.graphics.gui.elements.input.ButtonGuiElement
ButtonGuiElement is a
BaseInputGuiElement
that allows users to interact via clicking the button or using
keyboard shortcuts.-
Field Summary
Fields inherited from class technology.sola.engine.graphics.gui.GuiElement
children, contentBounds, styleContainer
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a ButtonGuiElement and adds default event listeners for handling disabled states and when theKey.SPACE
key is pressed. -
Method Summary
Modifier and TypeMethodDescription@Nullable GuiElementDimensions
Calculates content dimensions for this element.void
renderContent
(Renderer renderer) Method to render the main content of the gui element (not borders, backgrounds, etc.).setOnAction
(Runnable onAction) Sets the action that fires when the button is interacted with.Methods inherited from class technology.sola.engine.graphics.gui.elements.input.BaseInputGuiElement
isActive, isDisabled, isFocusable, isHovered, setDisabled
Methods inherited from class technology.sola.engine.graphics.gui.GuiElement
addStyle, addStyle, addStyles, appendChildren, events, findElementById, findElementsByType, findFocussedChildIndex, getAssetLoaderProvider, getBounds, getChildren, getContentBounds, getFocusableChildren, getId, getParent, invalidateLayout, isFocussed, isLayoutChanged, removeChild, render, renderChildren, requestFocus, setId, styles
-
Constructor Details
-
ButtonGuiElement
public ButtonGuiElement()Creates a ButtonGuiElement and adds default event listeners for handling disabled states and when theKey.SPACE
key is pressed.
-
-
Method Details
-
renderContent
Description copied from class:GuiElement
Method to render the main content of the gui element (not borders, backgrounds, etc.).- Specified by:
renderContent
in classGuiElement<BaseStyles,
ButtonGuiElement> - Parameters:
renderer
- theRenderer
instance
-
calculateContentDimensions
Description copied from class:GuiElement
Calculates content dimensions for this element. If its dimensions are derived from only its children then it should return null.- Specified by:
calculateContentDimensions
in classGuiElement<BaseStyles,
ButtonGuiElement> - Returns:
- the dimensions of the content of this element or null if only children dimensions matter
-
setOnAction
Sets the action that fires when the button is interacted with.- Parameters:
onAction
- the action to execute on button interaction- Returns:
- this
-