H3lp Yours3lfDocs
api

numberInput

Edit a number with commit-time clamping and stepping.

Builds a TextEdit that preserves raw text while editing and normalizes it on focus loss. Invalid text reverts to the last value; integer = true rounds to integral values.

Example

local ui = require 'openmw.ui'
local numberInput = require 'scripts.s3.components.numberInput'

local amount = 20
local element

element = ui.create {
  type = ui.TYPE.Container,
  layer = 'Windows',
  content = ui.content {
    numberInput {
      value = amount,
      min = 5,
      max = 100,
      step = 5,
      integer = true,
      onChange = function(value)
        amount = value
        print('Changed:', value)
      end,
      onCommit = function(value)
        print('Committed:', value)
        element:update()
      end,
    },
  },
}

Parameters

FieldTypeDescription
valuenumberInitial numeric value.
minnumber?Lower bound.
maxnumber?Upper bound.
stepnumber?Commit-time increment.
integerboolean?Round committed values to integers.
onChangefunction?Runs when the committed number changes.
onCommitfunction?Runs after every focus-loss commit.
templateopenmw.ui.Template?Replaces the default text-edit template.

Common layout fields are documented on the UI Components overview. Integer min, max, and step must themselves be integral.

See also

textInput · slider · searchInput