A unit input (unitInput) state variable represents a user numeric input value with multiple possible units. The app may provide the user a choice of their desired units for the number. The app can also choose which units it wants to compute with independent of the user's choice. Each rendered component will display according to the format and limits specified for the chosen unit in the state variable.
The unit input contains several child numericInput state variables, one for each unit is supports. Each child state variable is published with a subName corresponding to its unit (e.g., 'myPage_mySv_kg' and 'myPage_mySv_lb'). When one child state variable changes, the others are updated with the new value converted to their respective units.
Each unit input has an associated unitClass string. Each unitClass is associated with a unitSelector state variable. The unitSelector state variable controls which unit each rendered component will be displayed to the user. Many unitInput state variables can have the same unitClass, and, therefore will be controlled by the same unitSelector.
The unitInput state variable's component instance will display the currently selected unit sibling. If the showUnits attribute or the '{{...@}}' template syntax is used, the component will also display the appropriate unit abbreviations for the currently selected unit.
The app code or a component template may also refer to a specific child numericInput state variable. Any modification to that child will also update its siblings with converted values.
MVCS supports three types of numeric input mechanisms: a physical or virtual keyboard, a popup keypad, or a thumbwheel. The app Settings page can select the desired input mechanism for each device type by setting the set_inputType state variable. See Standard Settings Page.
unitInput', class: UnitInputSvctl.createPage({
...,
stateVarInfo:[
{type:'unitInput', ...},
],
})
info
An object containing the state variable properties. The info object can contain the following properties, but subclasses of StateVar may have additional properties:
info properties.info properties.info properties.unitClassunitClass string for the unitSelector that controls which unit sibling is current for this state variable.unitsinfo object. The first unit info object that supplies a max key is considered the primary unit sibling. If no child state variable supplies a max key, then the first key is considered primary. If a sibling does not declare a max or min value, then the max and/or min values from the primary sibling will be converted to the max and min values for that sibling.The object for each unit has the following keys:
fmt (optional)
The fmt parameter can be one of the following:
fmtStr). If a format string is used, then a NumFmt instance will be created using this string along with any info.min and info.amx parameters. If no fmt is provided, a format string of '8' is assumed.
min (optional)
The minimum valid value. This is ignored if a NumFmt instance is provided in the fmt parameter.
max (optional)
The maximum valid value. This is ignored if a NumFmt instance is provided in the fmt parameter.
Note: The component() method returns a NumInputSvCmp.
getSavedState()getSavedState()
Returns the state of the current unit sibling state variable.
Returns an object with the following keys:
unitvaluesetSavedState()setSavedState(state)
Sets the state variable to the internal state specified by state. If the state is invalid, the state variable has the option to set the state to the default state.
stategetSavedState().isNumberAlways true for unitInput.
A Boolean.
isUnitAlways true for unitInput.
A Boolean.
isUnitParentAlways true for unitInput.
A Boolean.
unitClassThe unitClass string for the unitSelector that controls which unit sibling is current for this state variable.
A String.
inputTypeThe inputType attribute establishes a particular user input type that overrides the set_inputType state variable if it exists. The values can be:
'keyboard''keypad''thumbwheel'A String.
plusMinusIf plusMinus is true, then "-" and "+" buttons will apear to the left and right of the input. Pressing one of the buttons will increment or decrement the value by fmt.rndMult.
A Boolean.
keyboard inputType, the numericInput Component will render an <input type="number"> with the value, max, min, and step attributes set according to the respective current numeric input state variable properties.<input> element may be converted to <input type="text"> when it loses focus.value attribute will be synchronized with the current unit sibling value. The min, max and step attributes will be synchronized with respective properties in the NumFmt instance in the current unit sibling's fmt property.<input> element will have a className that contains 'svIo_numInput'.inputType, the numericInput Component will render a <span>.<span> contents will be synchronized with the state variable value.