blockly > FieldNumber

FieldNumber class

Class for an editable number field.

Signature:

export declare class FieldNumber extends FieldInput<number> 

Extends: FieldInput<number>

Constructors

Constructor Modifiers Description
(constructor)(value, min, max, precision, validator, config) Constructs a new instance of the FieldNumber class

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