Skip to content

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 for String.
  • ofChar: A builder configured for Character.
  • ofByte: A builder configured for Byte.
  • ofShort: A builder configured for Short.
  • ofInteger: A builder configured for Integer.
  • ofLong: A builder configured for Long.
  • ofFloat: A builder configured for Float.
  • ofDouble: A builder configured for Double.
  • ofBigInteger: A builder configured for BigInteger.
  • ofBigDecimal: A builder configured for BigDecimal.
  • ofColor: A builder configured for Color.
  • ofAlphaColor: A builder configured for Color with alpha.
  • ofIdentifier: A builder configured for Identifier.
  • ofItem: A builder configured for Item.
  • ofBlock: A builder configured for Block.
  • ofEntity: A builder configured for EntityType.
  • ofVec2f: A builder configured for Vec2f.
  • ofVec3i: A builder configured for Vec3i.
  • ofVec3d: A builder configured for Vec3d.
  • ofBlockPos: A builder configured for BlockPos.
  • ofChunkPos: A builder configured for ChunkPos.

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: Returns true if the text can be parsed to a valid value.
  • isEditable: Returns true if 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: Returns true if a selection is active.
  • getFirstCharacterIndex: Gets the index of the leftmost visible character.

Example:

TextField.ofString()
.text("what up son")
.maxLength(32)
.build();