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 FieldTextInput 

Extends: FieldTextInput

Constructors

Constructor Modifiers Description
(constructor)(opt_value, opt_min, opt_max, opt_precision, opt_validator, opt_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.
SERIALIZABLE boolean Serializable fields are saved by the serializer, non-serializable fields are not. Editable fields should also be serializable.

Methods

Method Modifiers Description
configure_(config) protected Configure the field based on the given map of options.
doClassValidation_(opt_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.