Skip to content
S3ctor’s S3cret St4sh
api

window

Build a caller-owned movable and resizable framed surface.

Builds a framed Widget with an optional caption and body. It is not ui.TYPE.Window: H3 does not create a window, persist geometry, dock, or manage focus. Position and size are ordinary layout properties owned by the caller.

Example

local util = require 'openmw.util'

local position = util.vector2(80, 80)
local size = util.vector2(360, 220)
local pinned = false

ui.window {
  title = 'My tool H3UI.window',
  position = position,
  size = size,
  pinnable = true,
  pinned = pinned,
  onPin = function(value)
    pinned = value
  end,
  onMove = function(nextPosition)
    position = nextPosition
  end,
  onResize = function(nextSize, nextPosition)
    size = nextSize
    position = nextPosition
  end,
  children = {
    ui.text {
      text = 'Drag the caption or resize an edge.',
    },
  },
}

Parameters

FieldTypeDescription
titlestring?Optional caption text.
positionopenmw.util.Vector2?Initial position; defaults to 80×80.
sizeopenmw.util.Vector2?Initial size; defaults to 400×300.
minSizeopenmw.util.Vector2?Minimum size; defaults to 64×64.
maxSizeopenmw.util.Vector2?Optional maximum size.
movableboolean?Enables dragging; enabled by default.
resizableboolean?Enables edge resizing; enabled by default.
closableboolean?Adds a close control.
pinnableboolean?Adds a pin control.
pinnedboolean?Initial pin state.
innerBorderboolean?Adds the vanilla-style inner border below the caption; enabled by default.
paddingnumber?Empty space between the frame and the body on all four sides; defaults to 8.
onMovefunction?Receives the current position during movement.
onResizefunction?Receives size and position during resizing.
onClosefunction?Runs when close is pressed.
onPinfunction?Receives the new pin state.
clampToScreenboolean?Keeps movement within the screen.
referenceSizeopenmw.util.Vector2 or function?Coordinate space for nested windows.
captionHeightnumber?Caption strip height.
resizeHandlenumber?Resize hitbox; defaults to 4.
captionPropstable?Properties for the generated caption.
captionTextPropstable?Properties for the generated caption text.
backgroundPropstable?Properties for the generated background; H3UI themes use this slot for the configured background color and transparency.
contenttable?Body content; takes precedence over children.
childrentable?Body layouts used when content is absent.

Common layout fields are documented on the UI Components overview. The caller owns geometry, persistence, visibility, and destruction; H3 redraws its own mutations through the scope invalidator.

See also

caption · text