H3lp Yours3lfDocs
api

caption

Build a centered Morrowind title strip with optional controls.

Builds a horizontal title strip from head blocks and centered text. It can append a pin control and/or close button; it does not close a parent window. Give it a fixed-width Widget parent because its default width is relative.

Example

local ui = require 'openmw.ui'
local util = require 'openmw.util'
local caption = require 'scripts.s3.components.caption'

ui.create {
  layer = 'Windows',
  props = {
    size = util.vector2(320, 20),
  },
  content = ui.content {
    caption {
      text = 'Inventory',
      pinnable = true,
      closable = true,
      onPin = function(pinned)
        print('Pinned:', pinned)
      end,
      onClose = function()
        print('Closed')
      end,
    },
  },
}

Parameters

FieldTypeDescription
textstringCaption text.
pinnableboolean?Adds a pin control.
pinnedboolean?Initial pin state.
onPinfunction?Receives the new pin state.
closableboolean?Adds a close control.
onClosefunction?Runs when close is pressed.
closeLabelstring?Accessible close-button label.
heightnumber?Strip height; controls need at least 19.
textPropstable?Properties for the caption text.
pinPropstable?Properties for the pin control.
closePropstable?Properties for the close control.

Common layout fields are documented on the UI Components overview. The default relative width requires a parent with explicit width; use the default Widget with props.size for a standalone caption.

See also

headBlock · pinButton · window