H3lp Yours3lfDocs
api

selector

Choose one item with previous and next buttons.

Builds a horizontal row containing previous, value, and next controls. Items may be strings or { label, value } tables; the callback receives the original item.

Example

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

local modes = {
  'Compact',
  'Balanced',
  'Verbose',
}
local selected = 2
local element

element = ui.create {
  type = ui.TYPE.Container,
  layer = 'Windows',
  content = ui.content {
    selector {
      items = modes,
      selected = selected,
      onSelect = function(index, item)
        selected = index
        print('Mode:', item)
        element:update()
      end,
    },
  },
}

Parameters

FieldTypeDescription
itemstableStrings or { label, value } entries.
selectedinteger?Initial selected index.
onSelectfunction?Receives the index and original item.
emptyLabelstring?Text shown when there are no items.
buttonPropstable?Properties for previous and next buttons.
iconPropstable?Properties for arrow icons.
labelPropstable?Properties for the selected value.
labelTemplateopenmw.ui.Template?Template for the selected value.

Common layout fields are documented on the UI Components overview. Empty and one-item lists are valid and cannot move.

See also

tabs · button · list