Skip to content

NumberAccumulator

Overview

A key accumulator that collects user input for integer and floating point values, intended for use in conjunction with the common-code keypad.

@author Aadish Gupta @author John Blanco @author Chris Malley (PixelZoom, Inc.)

Class NumberAccumulator

import { NumberAccumulator } from 'scenerystack/scenery-phet';

Constructor

new NumberAccumulator( providedOptions? : NumberAccumulatorOptions )

Instance Methods

handleKeyPressed( keyIdentifier : KeyIDValue )

Invoked when a key is pressed and creates proposed set of keys to be passed to the validator @param keyIdentifier - identifier for the key pressed

clear()

clear the accumulator

dispose()

Instance Properties

stringProperty : ReadOnlyProperty<string>

(readonly)

string representation of the keys entered by the user

valueProperty : ReadOnlyProperty<number | null>

(readonly)

numerical value of the keys entered by the user

Type NumberAccumulatorOptions

import type { NumberAccumulatorOptions } from 'scenerystack/scenery-phet';
  • maxDigitsRightOfMantissa?: number
  • maxDigits?: number
  • & Pick<PhetioObjectOptions, "tandem" | "tandemNameSuffix">

Source Code

See the source for NumberAccumulator.ts in the scenery-phet repository.