Thread Tools Display Modes
10-07-15, 01:04 PM   #1
gerald101
A Kobold Labourer
Join Date: Oct 2015
Posts: 1
Text in the Frames

Alright, so I started to learn some of the basics with lua as far as addon programming and I was hoping that someone could post a simple example of putting text into a frame. For example...if I put an action button in the frame and wanted to put a label above it that says what it does...

Thank you all
  Reply With Quote
10-07-15, 02:08 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Frame:
Code:
local frame = CreateFrame("Frame", "MyExampleFrame", UIParent)
frame:SetPoint("CENTER")
frame:SetSize(100, 50)
Texture:
Code:
frame.texture = frame:CreateTexture(nil, "BACKGROUND")
frame.texture:SetAllPoints(true)
frame.texture:SetTexture(1, 1, 1, 0.5)
Font string:
Code:
frame.text = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
frame.text:SetPoint("BOTTOM", frame, "TOP", 5, 0)
frame.text:SetText("This is my frame!")
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
10-07-15, 02:14 PM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
Lua Code:
  1. --  Frames need a position and size set in order to be visible (Size can also be set using multiple anchor points)
  2. local frame=CreateFrame("Frame","FrameName",UIParent);--    Our frame
  3. frame:SetPoint("CENTER");
  4. frame:SetSize(100,100);
  5.  
  6. --  FontStrings only need a position set. By default, they size automatically according to the text shown.
  7. local text=frame:CreateFontString(nil,"OVERLAY","GameFontNormal");--    Our text area
  8. text:SetPoint("CENTER");
  9. text:SetText("Sample Text");
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Text in the Frames


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off