blockly > FieldTextInput > (constructor)
FieldTextInput.(constructor)
Constructs a new instance of the FieldTextInput
class
Signature:
constructor(value?: string | typeof Field.SKIP_SETUP, validator?: FieldTextInputValidator | null, config?: FieldTextInputConfig);
Parameters
Parameter |
Type |
Description |
value |
string | typeof Field.SKIP_SETUP |
(Optional) The initial value of the field. Should cast to a string. Defaults to an empty string if null or undefined. Also accepts Field.SKIP_SETUP if you wish to skip setup (only used by subclasses that want to handle configuration and setting the field value after their own constructors have run). |
validator |
FieldTextInputValidator | null |
(Optional) A function that is called to validate changes to the field's value. Takes in a string & returns a validated string, or null to abort the change. |
config |
FieldTextInputConfig |
(Optional) A map of options used to configure the field. See the [field creation documentation]https://developers.google.com/blockly/guides/create-custom-blocks/fields/built-in-fields/text-input#creation for a list of properties this parameter supports. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[null,null,["Last updated 2024-09-18 UTC."],[[["The `FieldTextInput` constructor creates new text input fields within Blockly blocks, accepting an initial value, a validator function, and a configuration object."],["The `value` parameter sets the starting text, defaulting to an empty string, while the `validator` parameter enforces data integrity by allowing custom validation logic on user input."],["Developers can customize the field's appearance and behavior through the `config` parameter, referring to Blockly's documentation for available options."]]],["The `FieldTextInput` class constructor creates a new text input field. It accepts three optional parameters: `value`, which sets the initial string value, defaulting to an empty string; `validator`, a function to validate value changes; and `config`, a map of options for field configuration. The `value` parameter can also be set to `Field.SKIP_SETUP` to defer setup, useful for subclasses. The field creation documentation provides details on the supported `config` properties.\n"]]