Package com.tonic.vellum.widget
Class TextInput
- java.lang.Object
-
- com.tonic.vellum.Section
-
- com.tonic.vellum.widget.TextInput
-
public final class TextInput extends Section
A single-line editable text field with caret movement and horizontal scrolling. Enter fires onSubmit; edits fire onChange. Do not pair a printable quit key with a focused TextInput (it would be typed); use a non-printable quit such as Ctrl-C or Escape.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TextInputonChange(java.util.function.Consumer<java.lang.String> handler)Sets the handler called with the current text after every edit.TextInputonSubmit(java.util.function.Consumer<java.lang.String> handler)Sets the handler called with the current text when Enter is pressed.TextInputplaceholder(java.lang.String placeholder)Sets the placeholder shown when the field is empty and unfocused.TextInputplaceholderStyle(Style style)Sets the style used to draw the placeholder.TextInputsetText(java.lang.String value)Sets the field text, moving the caret to the end.TextInputstyle(Style style)Sets the style used to draw the text.java.lang.Stringtext()
-
-
-
Method Detail
-
setText
public TextInput setText(java.lang.String value)
Sets the field text, moving the caret to the end. Anullvalue clears the field.- Parameters:
value- the new text- Returns:
- this TextInput for chaining
-
text
public java.lang.String text()
- Returns:
- the current text
-
placeholder
public TextInput placeholder(java.lang.String placeholder)
Sets the placeholder shown when the field is empty and unfocused. Anullvalue is treated as empty.- Parameters:
placeholder- the placeholder text- Returns:
- this TextInput for chaining
-
style
public TextInput style(Style style)
Sets the style used to draw the text.- Parameters:
style- the text style- Returns:
- this TextInput for chaining
-
placeholderStyle
public TextInput placeholderStyle(Style style)
Sets the style used to draw the placeholder.- Parameters:
style- the placeholder style- Returns:
- this TextInput for chaining
-
onSubmit
public TextInput onSubmit(java.util.function.Consumer<java.lang.String> handler)
Sets the handler called with the current text when Enter is pressed.- Parameters:
handler- the submit handler- Returns:
- this TextInput for chaining
-
onChange
public TextInput onChange(java.util.function.Consumer<java.lang.String> handler)
Sets the handler called with the current text after every edit.- Parameters:
handler- the change handler- Returns:
- this TextInput for chaining
-
-