Skip to content
S3ctor’s S3cret St4sh
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.h3.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; defaults to 20. Captions with pin or close controls require at least 20; captions without controls require at least 4.
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