Skip to content

TextFieldWidgetHelper.TextFieldBuilder ​

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

Since1.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.

Constructors ​

new TextFieldWidgetHelper.TextFieldBuilder ​

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 ​

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) changes also invoke it.

Parameters:

  • action: the callback for when the text is changed
Returns: self for chaining.

createWidget ​

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 ​

getAction(): MethodWrapper<String, IScreen, Object, ?>Since1.8.4#
Returns the configured text-change callback, or null if none is set.
Returns: the callback for when the text is changed.

getSuggestion ​

getSuggestion(): StringSince1.8.4#
Returns the configured hint, initially an empty string.
Returns: the current suggestion.

suggestion ​

suggestion(String suggestion): TextFieldWidgetHelper.TextFieldBuilderSince1.8.4#
Sets the hint drawn while the field is empty; it is not part of the field's value returned by TextFieldWidgetHelper.getText().

Parameters:

  • suggestion: the suggestion to use
Returns: self for chaining.