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.SPACEkey is pressed. -
Method Summary
Modifier and TypeMethodDescription@Nullable GuiElementDimensionsCalculates content dimensions for this element.voidrenderContent(Renderer renderer) Method to render the main content of the gui element (not borders, backgrounds, etc.).self()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, setDisabledMethods inherited from class technology.sola.engine.graphics.gui.GuiElement
addStyle, addStyle, addStyles, appendChildren, events, findElementById, findElementsByType, findFocussedChildIndex, getAssetLoaderProvider, getBounds, getContentBounds, getFocusableChildren, getId, getParent, invalidateLayout, isAttached, isFocussed, isLayoutChanged, removeChild, render, renderChildren, requestFocus, setId, setVirtualKeyboardVisible, styles
-
Constructor Details
-
ButtonGuiElement
public ButtonGuiElement()Creates a ButtonGuiElement and adds default event listeners for handling disabled states and when theKey.SPACEkey is pressed.
-
-
Method Details
-
renderContent
Description copied from class:GuiElementMethod to render the main content of the gui element (not borders, backgrounds, etc.).- Specified by:
renderContentin classGuiElement<BaseStyles,ButtonGuiElement> - Parameters:
renderer- theRendererinstance
-
calculateContentDimensions
Description copied from class:GuiElementCalculates content dimensions for this element. If its dimensions are derived from only its children then it should return null.- Specified by:
calculateContentDimensionsin classGuiElement<BaseStyles,ButtonGuiElement> - Returns:
- the dimensions of the content of this element or null if only children dimensions matter
-
self
- Specified by:
selfin classGuiElement<BaseStyles,ButtonGuiElement> - Returns:
- A correctly typed reference to this
GuiElement
-
setOnAction
Sets the action that fires when the button is interacted with.- Parameters:
onAction- the action to execute on button interaction- Returns:
- this
-