# TextFieldWidgetHelper.TextFieldBuilder

`com.jsmacrosce.jsmacros.client.api.helper.screen.TextFieldWidgetHelper.TextFieldBuilder`

**Since:** 1.8.4

Builds text-field widgets using the screen's font and configured dimensions.  
 The configured callback is attached when the widget is built.

Nested type declared in [TextFieldWidgetHelper](TextFieldWidgetHelper.md).

## Constructors

### new TextFieldWidgetHelper.TextFieldBuilder {#com.jsmacrosce.jsmacros.client.api.helper.screen.TextFieldWidgetHelper.TextFieldBuilder_constructor-IScreen-Font-}

```js
new TextFieldWidgetHelper.TextFieldBuilder(IScreen screen, Font textRenderer)
```

Stores the screen used for widget addition and the font used to create text fields.

**Parameters:**
- `screen`: the screen associated with this builder
- `textRenderer`: the font used to create text fields

## Methods

### action {#com.jsmacrosce.jsmacros.client.api.helper.screen.TextFieldWidgetHelper.TextFieldBuilder_action-MethodWrapper-}

```js
action(MethodWrapper<String, IScreen, Object, ?> action): TextFieldWidgetHelper.TextFieldBuilder
```

Sets the callback for accepted text changes. It receives the new text and
 the screen used to create this builder; it is attached when the field is built.  
 Scripted [TextFieldWidgetHelper.setText(String)](TextFieldWidgetHelper.md#com.jsmacrosce.jsmacros.client.api.helper.screen.TextFieldWidgetHelper_setText-String-) changes also invoke it.

**Parameters:**
- `action`: the callback for when the text is changed

**Returns:** self for chaining.

**Since:** 1.8.4

### createWidget {#com.jsmacrosce.jsmacros.client.api.helper.screen.TextFieldWidgetHelper.TextFieldBuilder_createWidget-}

```js
createWidget(): TextFieldWidgetHelper
```

Creates a configured text field and helper, attaching the configured callback.  
 The field is not added to the screen and build-time alpha, active, and visible
 settings are not applied until `build()` is called.

**Returns:** the helper for the newly created text field

### getAction {#com.jsmacrosce.jsmacros.client.api.helper.screen.TextFieldWidgetHelper.TextFieldBuilder_getAction-}

```js
getAction(): MethodWrapper<String, IScreen, Object, ?>
```

Returns the configured text-change callback, or `null` if none is set.

**Returns:** the callback for when the text is changed.

**Since:** 1.8.4

### getSuggestion {#com.jsmacrosce.jsmacros.client.api.helper.screen.TextFieldWidgetHelper.TextFieldBuilder_getSuggestion-}

```js
getSuggestion(): String
```

Returns the configured hint, initially an empty string.

**Returns:** the current suggestion.

**Since:** 1.8.4

### suggestion {#com.jsmacrosce.jsmacros.client.api.helper.screen.TextFieldWidgetHelper.TextFieldBuilder_suggestion-String-}

```js
suggestion(String suggestion): TextFieldWidgetHelper.TextFieldBuilder
```

Sets the hint drawn while the field is empty; it is not part of the field's
 value returned by [TextFieldWidgetHelper.getText()](TextFieldWidgetHelper.md#com.jsmacrosce.jsmacros.client.api.helper.screen.TextFieldWidgetHelper_getText-).

**Parameters:**
- `suggestion`: the suggestion to use

**Returns:** self for chaining.

**Since:** 1.8.4
