Stay organized with collections
Save and categorize content based on your preferences.
blockly > FieldNumber
FieldNumber class
Class for an editable number field.
Signature:
export declare class FieldNumber extends FieldInput<number>
Extends: FieldInput<number>
Constructors
Properties
Property |
Modifiers |
Type |
Description |
max_ |
protected |
number |
The maximum value this number field can contain. |
min_ |
protected |
number |
The minimum value this number field can contain. |
precision_ |
protected |
number |
The multiple to which this fields value is rounded. |
spellcheck_ |
protected |
boolean |
Don't spellcheck numbers. Our validator does a better job. |
Methods
Method |
Modifiers |
Description |
configure_(config) |
protected |
Configure the field based on the given map of options. |
doClassValidation_(newValue) |
protected |
Ensure that the input value is a valid number (must fulfill the constraints placed on the field). |
getMax() |
|
Returns the current maximum value this field can contain. Default is Infinity. |
getMin() |
|
Returns the current minimum value this field can contain. Default is -Infinity. |
getPrecision() |
|
Returns the current precision of this field. The precision being the number to which the field's value is rounded. A precision of 0 means that the value is not rounded. |
initView() |
|
Initialize the field's DOM. |
setConstraints(min, max, precision) |
|
Set the maximum, minimum and precision constraints on this field. Any of these properties may be undefined or NaN to be disabled. Setting precision (usually a power of 10) enforces a minimum step between values. That is, the user's value will rounded to the closest multiple of precision. The least significant digit place is inferred from the precision. Integers values can be enforces by choosing an integer precision. |
setMax(max) |
|
Sets the maximum value this field can contain. Updates the value to reflect. |
setMin(min) |
|
Sets the minimum value this field can contain. Updates the value to reflect. |
setPrecision(precision) |
|
Sets the precision of this field's value, i.e. the number to which the value is rounded. Updates the field to reflect. |
widgetCreate_() |
protected |
Create the number input editor widget. |
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 2025-05-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-16 UTC."],[[["\u003cp\u003e\u003ccode\u003eFieldNumber\u003c/code\u003e is a Blockly class for creating editable number input fields within blocks.\u003c/p\u003e\n"],["\u003cp\u003eIt inherits from \u003ccode\u003eFieldInput\u003c/code\u003e and allows setting minimum, maximum, and precision constraints for the input.\u003c/p\u003e\n"],["\u003cp\u003eThe class provides methods for configuring, validating, and retrieving the field's properties like value, constraints, and precision.\u003c/p\u003e\n"],["\u003cp\u003eUsers can programmatically set and adjust the constraints and precision of the number field to control user input.\u003c/p\u003e\n"],["\u003cp\u003eThe class handles the creation and management of the underlying HTML input element for the number field.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [FieldNumber](./blockly.fieldnumber_class.md)\n\nFieldNumber class\n-----------------\n\nClass for an editable number field.\n\n**Signature:** \n\n export declare class FieldNumber extends FieldInput\u003cnumber\u003e \n\n**Extends:** FieldInput\\\u003cnumber\\\u003e\n\nConstructors\n------------\n\n| Constructor | Modifiers | Description |\n|----------------------------------------------------------------------------------------------------------------------------|-----------|------------------------------------------------------|\n| [(constructor)(value, min, max, precision, validator, config)](./blockly.fieldnumber_class._constructor__1_constructor.md) | | Constructs a new instance of the `FieldNumber` class |\n\nProperties\n----------\n\n| Property | Modifiers | Type | Description |\n|--------------------------------------------------------------------|-------------|---------|------------------------------------------------------------|\n| [max_](./blockly.fieldnumber_class.max__property.md) | `protected` | number | The maximum value this number field can contain. |\n| [min_](./blockly.fieldnumber_class.min__property.md) | `protected` | number | The minimum value this number field can contain. |\n| [precision_](./blockly.fieldnumber_class.precision__property.md) | `protected` | number | The multiple to which this fields value is rounded. |\n| [spellcheck_](./blockly.fieldnumber_class.spellcheck__property.md) | `protected` | boolean | Don't spellcheck numbers. Our validator does a better job. |\n\nMethods\n-------\n\n| Method | Modifiers | Description |\n|-----------------------------------------------------------------------------------------------|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [configure_(config)](./blockly.fieldnumber_class.configure__1_method.md) | `protected` | Configure the field based on the given map of options. |\n| [doClassValidation_(newValue)](./blockly.fieldnumber_class.doclassvalidation__1_method.md) | `protected` | Ensure that the input value is a valid number (must fulfill the constraints placed on the field). |\n| [getMax()](./blockly.fieldnumber_class.getmax_1_method.md) | | Returns the current maximum value this field can contain. Default is Infinity. |\n| [getMin()](./blockly.fieldnumber_class.getmin_1_method.md) | | Returns the current minimum value this field can contain. Default is -Infinity. |\n| [getPrecision()](./blockly.fieldnumber_class.getprecision_1_method.md) | | Returns the current precision of this field. The precision being the number to which the field's value is rounded. A precision of 0 means that the value is not rounded. |\n| [initView()](./blockly.fieldnumber_class.initview_1_method.md) | | Initialize the field's DOM. |\n| [setConstraints(min, max, precision)](./blockly.fieldnumber_class.setconstraints_1_method.md) | | Set the maximum, minimum and precision constraints on this field. Any of these properties may be undefined or NaN to be disabled. Setting precision (usually a power of 10) enforces a minimum step between values. That is, the user's value will rounded to the closest multiple of precision. The least significant digit place is inferred from the precision. Integers values can be enforces by choosing an integer precision. |\n| [setMax(max)](./blockly.fieldnumber_class.setmax_1_method.md) | | Sets the maximum value this field can contain. Updates the value to reflect. |\n| [setMin(min)](./blockly.fieldnumber_class.setmin_1_method.md) | | Sets the minimum value this field can contain. Updates the value to reflect. |\n| [setPrecision(precision)](./blockly.fieldnumber_class.setprecision_1_method.md) | | Sets the precision of this field's value, i.e. the number to which the value is rounded. Updates the field to reflect. |\n| [widgetCreate_()](./blockly.fieldnumber_class.widgetcreate__1_method.md) | `protected` | Create the number input editor widget. |"]]