Label

This function creates a label widget. A label is a non-interactive widget that displays a line of text.

You can set the boolean value border to true to display a border around the label and increase the widget padding.

Syntax

Parameters

Returns

Returns a new label.

Example

local window = Window:Create()
local context = Context:Create(window)
local gui = GUI:Create(context)
local base = gui:GetBase()
base:SetScript("Scripts/GUI/Panel.lua")

x=20
y=20
local sep=30

widget = Widget:Label("Default",x,y,300,20,base)
y=y+sep

widget = Widget:Label("Left with border",x,y,300,20,base)
widget:SetStyle(LABEL_BORDER)
y=y+sep

widget = Widget:Label("Center with border",x,y,300,20,base)
widget:SetStyle(LABEL_BORDER + LABEL_CENTER)
y=y+sep

widget = Widget:Label("Right with border",x,y,300,20,base)
widget:SetStyle(LABEL_BORDER + LABEL_RIGHT)
y=y+sep

widget = Widget:Label("Center with border and vertical align",x,y,300,80,base)
widget:SetStyle(LABEL_BORDER + LABEL_CENTER + LABEL_MIDDLE)
y=y+90

widget = Widget:Label("Sometimes a label just has too much text to fit in its space. When this happens, just use the worwrap option!",x,y,300,80,base)
widget:SetStyle(LABEL_BORDER + LABEL_WRAP)
y=y+sep

while true do
if window:Closed() then return end
if window:KeyHit(Key.Escape) then return end

while EventQueue:Peek() do
local event = EventQueue:Wait()
if event.id == Event.WidgetAction then
System:Print("WidgetAction")
elseif event.id == Event.WidgetSelect then
System:Print("WidgetSelect")
end
end

context:Sync()
end