Перейти к основному содержимому

NumberInput()

A field that only takes a number. The answer is a number.

Constructor​

NumberInput(id: number, hint: string)
NumberInput(id: number, hint: string, default: number)

Parameters​

ParametersTypeDescription
idnumberThe question's id, for Dialog:getValueById()
hintstringThe label on the field
defaultnumberOptional. The number before the user types one

Example​

Dialog:add(NumberInput(2, "Runs", 10):setRange(1, 999))
Dialog:show()
local runs = Dialog:getValueById(2)

Notes​

  • The user must enter a number: OK stays grey while the field is empty or holds something else. setRequired(false) allows it to be empty, and the answer is then nil.
  • setRange(min, max) keeps the number between two values.
  • Decimals and negative numbers are allowed.