Class TextInput.Builder
- Enclosing class:
TextInput
Builds a
TextInput; from TextInput.builder(String). Also has the options every entry has (Entry.Builder).-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the field.The text the field starts with, usually the mod's current value; empty by default.A fixed label; seelabel(Supplier).The text above the field, re-read on every refresh.maxLength(int maxLength) The most characters the field accepts; 64 by default.Receives the text after each edit that leaves it valid, on the main thread.Checks the text after every edit and refresh: returns an error text for invalid input (shown below the field),nullfor valid input.
-
Method Details
-
label
The text above the field, re-read on every refresh. Required.- Parameters:
label- read on refresh- Returns:
- this builder
-
label
A fixed label; seelabel(Supplier).- Parameters:
label- the label- Returns:
- this builder
-
initial
The text the field starts with, usually the mod's current value; empty by default. Cut tomaxLength. Not passed toonChange.- Parameters:
initial- the starting text- Returns:
- this builder
-
maxLength
The most characters the field accepts; 64 by default. Must be positive.- Parameters:
maxLength- the limit- Returns:
- this builder
-
validator
Checks the text after every edit and refresh: returns an error text for invalid input (shown below the field),nullfor valid input. Runs on the main thread, often: keep it fast. By default every text is valid.- Parameters:
validator- maps the text to an error, ornull- Returns:
- this builder
-
onChange
Receives the text after each edit that leaves it valid, on the main thread. Optional.- Parameters:
onChange- receives valid text- Returns:
- this builder
-
build
Builds the field.- Returns:
- the field
- Throws:
IllegalStateException- iflabelis missing ormaxLengthis not positive
-