H3lp Yours3lfDocs
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 ui = require 'openmw.ui'
local util = require 'openmw.util'
local text = require 'scripts.s3.components.text'
local window = require 'scripts.s3.components.window'

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

element = ui.create {
  type = ui.TYPE.Container,
  layer = 'Windows',
  content = ui.content {
    window {
      title = 'My tool window',
      position = position,
      size = size,
      pinnable = true,
      pinned = pinned,
      closable = true,
      onPin = function(value)
        pinned = value
        element:update()
      end,
      onClose = function()
        element:destroy()
      end,
      onMove = function(nextPosition)
        position = nextPosition
        element:update()
      end,
      onResize = function(nextSize, nextPosition)
        size = nextSize
        position = nextPosition
        element:update()
      end,
      children = {
        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.
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, redraw, and destruction.

See also

caption · dialog · text