H3lp Yours3lfDocs
api

button

Build an H3UI text button.

Builds an H3UI text button using OpenMW's built-in box template. label creates the default padded text child; custom content or children replaces it.

Example

local async = require 'openmw.async'
local ui = require 'openmw.ui'
local button = require 'scripts.s3.components.button'

ui.create {
  type = ui.TYPE.Container,
  layer = 'Windows',
  content = ui.content {
    button {
      label = 'Press me',
      events = {
        mouseClick = async:callback(function()
          print('Button pressed')
          return true
        end),
      },
    },
  },
}

Parameters

FieldTypeDescription
labelstring?Text for the generated button label.
labelPropstable?Properties for the generated label.
contenttable?Custom content; replaces the generated label.
childrentable?Custom child layouts when content is absent.
templateopenmw.ui.Template?Replaces the default H3UI button template.

Common layout fields are documented on the UI Components overview.

Wrap OpenMW callbacks with async:callback; H3 passes low-level events through unchanged.

See also

toggle · iconButton · dialog