Skip to content

Widget Spec

A “widget” in the Baz suite is a plain Lua table describing a frame to host. There’s no constructor — you populate the fields you need and pass the table to the registry.

FieldTypeDescription
idstringUnique widget id. Convention: <addon>_<name> (e.g. bazwidgets_repair).
frameFrameThe actual Frame object the host will parent.
FieldTypeDescription
labelstringTitle bar text.
iconstring|tableTexture path or atlas info.
designWidthnumberNative width — host scales to fit.
designHeightnumberInitial height hint.
sourcestringFree-form provenance label, e.g. "LibDataBroker".
tagsarraySmall chips next to the label, each { text, color }.

These are optional methods you put on the widget table (or its frame). The host calls them when present.

MethodWhen called
widget:GetDesiredHeight() -> numberWhenever the host reflows. Return your dynamic height.
widget:GetStatusText() -> text, r, g, bWhen the title bar’s status segment refreshes.
widget:GetOptionsArgs() -> tableWhen the host builds the per-widget options page. AceConfig-style table.
widget:OnDock(host)When the widget is parented into a drawer.
widget:OnUndock()When the widget is detached or unregistered.

If your widget’s height changes (collapsing a section, switching layouts), tell the host so it can rebuild the slot stack:

local bd = BazCore:GetAddon("BazWidgetDrawers")
if bd and bd.WidgetHost then
bd.WidgetHost:Reflow()
end

For status-text-only changes, use WidgetHost:UpdateWidgetStatus(widgetId) instead — it’s lighter than a reflow.

local f = CreateFrame("Frame", nil, UIParent)
f:SetSize(200, 22)
f.text = f:CreateFontString(nil, "OVERLAY", "GameFontNormal")
f.text:SetPoint("LEFT", 6, 0)
f.text:SetText("Hello")
local widget = {
id = "myaddon_hello",
label = "Hello",
icon = "Interface\\Icons\\inv_misc_book_09",
designWidth = 200,
designHeight = 22,
frame = f,
GetStatusText = function(self)
return f.text:GetText() or "", 1, 0.82, 0
end,
}
BazCore:RegisterDockableWidget(widget)

Continue to Publishing Widgets for the full publisher API and dormant widgets.