H3lp Yours3lfDocs
api

iconButton

Build an H3UI button with a caller-provided icon and optional label.

Builds an H3UI button with a centered row containing an image and, optionally, a label. Pass a texture resource or texture options for the icon.

Example

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

ui.create {
  type = ui.TYPE.Container,
  layer = 'Windows',
  content = ui.content {
    iconButton {
      label = 'Map',
      resource = {
        path = 'white',
      },
      events = {
        mouseClick = async:callback(function()
          print('Map pressed')
          return true
        end),
      },
    },
  },
}

Parameters

FieldTypeDescription
resourceopenmw.ui.TextureResource or openmw.ui.TextureResourceOptionsIcon texture resource or options for one.
labelstring?Optional text beside the icon.
iconPropstable?Properties for the icon.
labelPropstable?Properties for the label.
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.

See also

button · image · itemSlot