Module technology.sola.engine
Class TextInputGuiElement
java.lang.Object
technology.sola.engine.graphics.gui.GuiElement<Style,ElementType>
technology.sola.engine.graphics.gui.elements.input.BaseInputGuiElement<TextInputStyles,TextInputGuiElement>
technology.sola.engine.graphics.gui.elements.input.TextInputGuiElement
@NullMarked
public class TextInputGuiElement
extends BaseInputGuiElement<TextInputStyles,TextInputGuiElement>
TextInputGuiElement is a
BaseInputGuiElement
that allows users to interact via typing text into the field.-
Field Summary
Fields inherited from class technology.sola.engine.graphics.gui.GuiElement
children, contentBounds, styleContainer
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance of TextInputGuiElement registering default event listeners for typing characters into the field. -
Method Summary
Modifier and TypeMethodDescriptionappendChildren
(GuiElement<?, ?>... children) TextInputGuiElement does not render children so this method will do nothing.Calculates content dimensions for this element.List<GuiElement<?,
?>> TextInputGuiElement does not render children so this method will return an empty List.@Nullable Integer
getValue()
removeChild
(GuiElement<?, ?> child) TextInputGuiElement does not render children so this method will do nothing.void
renderContent
(Renderer renderer) Method to render the main content of the gui element (not borders, backgrounds, etc.).setMaxLength
(@Nullable Integer maxLength) Sets the maximum number of characters allowed for the input.setPlaceholder
(String placeholder) Sets the placeholder text for when no user value is entered.Programmatically sets the user entered value of the input.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, events, findElementById, findElementsByType, findFocussedChildIndex, getAssetLoaderProvider, getBounds, getContentBounds, getFocusableChildren, getId, getParent, invalidateLayout, isFocussed, isLayoutChanged, render, renderChildren, requestFocus, setId, styles
-
Constructor Details
-
TextInputGuiElement
public TextInputGuiElement()Creates an instance of TextInputGuiElement registering default event listeners for typing characters into the field.
-
-
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<TextInputStyles,
TextInputGuiElement> - 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<TextInputStyles,
TextInputGuiElement> - Returns:
- the dimensions of the content of this element or null if only children dimensions matter
-
appendChildren
TextInputGuiElement does not render children so this method will do nothing.- Overrides:
appendChildren
in classGuiElement<TextInputStyles,
TextInputGuiElement> - Parameters:
children
- the child elements to add- Returns:
- this
-
removeChild
TextInputGuiElement does not render children so this method will do nothing.- Overrides:
removeChild
in classGuiElement<TextInputStyles,
TextInputGuiElement> - Parameters:
child
- the child element that will not be removed- Returns:
- this
-
getChildren
TextInputGuiElement does not render children so this method will return an empty List.- Overrides:
getChildren
in classGuiElement<TextInputStyles,
TextInputGuiElement> - Returns:
- empty List
-
getPlaceholder
- Returns:
- the placeholder when no user value is entered
-
setPlaceholder
Sets the placeholder text for when no user value is entered.- Parameters:
placeholder
- the new placeholder text- Returns:
- this
-
getMaxLength
- Returns:
- the maximum number of characters allowed for the input
-
setMaxLength
Sets the maximum number of characters allowed for the input. If the new length is smaller than the entered value it will be truncated down to the new max length.- Parameters:
maxLength
- the new max length- Returns:
- this
-
getValue
- Returns:
- the user entered value in the input
-
setValue
Programmatically sets the user entered value of the input.- Parameters:
value
- the new value of the input- Returns:
- this
-