Text Field
Extends BentoElement and implements ValueElement<T>.
The text field accepts text input and can represent any parseable type.
Builders:
builder: The default builder.ofString: A builder configured forString.ofChar: A builder configured forCharacter.ofByte: A builder configured forByte.ofShort: A builder configured forShort.ofInteger: A builder configured forInteger.ofLong: A builder configured forLong.ofFloat: A builder configured forFloat.ofDouble: A builder configured forDouble.ofBigInteger: A builder configured forBigInteger.ofBigDecimal: A builder configured forBigDecimal.ofColor: A builder configured forColor.ofAlphaColor: A builder configured forColorwith alpha.ofIdentifier: A builder configured forIdentifier.ofItem: A builder configured forItem.ofBlock: A builder configured forBlock.ofEntity: A builder configured forEntityType.ofVec2f: A builder configured forVec2f.ofVec3i: A builder configured forVec3i.ofVec3d: A builder configured forVec3d.ofBlockPos: A builder configured forBlockPos.ofChunkPos: A builder configured forChunkPos.
Builder methods:
text: The text.- getter / setter
maxLength: The max length of the text.- getter / setter
editableColor: The text color when this text field is editable.- getter / setter
uneditableColor: The text color when this text field is uneditable.- getter / setter
invalidColor: The text color when the input is invalid.- getter / setter
placeholder: The placeholder text.- getter / setter
character: Sets the text field to a single character input mode.onChange: The function to run when this text field is changed.- setter
valueParser: The function to use to parse the text into a value.valueStringifier: The function to use to stringify the value.inputPredicate: The predicate to use to check if the input string is allowed.- setter
validationPredicate: The predicate to use to check if the text can be parsed to a valid value.- setter
Class methods:
getTextColor: Gets the current text color.isValidText: Returnstrueif the text can be parsed to a valid value.isEditable: Returnstrueif the text field is editable.setEditable: Sets the editable state of the text field.getCursor: Gets the cursor index.setCursor: Sets the cursor index.setCursorToStart: Sets the cursor to the start.setCursorToEnd: Sets the cursor to the end.moveCursor: Moves the cursor.getSelectionMin: Gets the index of the left edge of the selection.getSelectionMax: Gets the index of the right edge of the selection.getSelectedText: Gets the selected text.isSelectionActive: Returnstrueif a selection is active.getFirstCharacterIndex: Gets the index of the leftmost visible character.
Example:
TextField.ofString() .text("what up son") .maxLength(32) .build();