View Single Post
08-03-08, 04:50 PM   #5
Freki
A Deviate Faerie Dragon
 
Freki's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 18
A simple example to help you get started maybe. Creating a draggable frame with a backdrop and close button using only lua. (untested, should work)

Code:
local MyAddon = CreateFrame("frame","MyAddonFrame")
MyAddon:SetBackdrop({
      bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", 
      edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border", 
      tile=1, tileSize=32, edgeSize=32, 
      insets={left=11, right=12, top=12, bottom=11}
})
MyAddon:SetWidth(220)
MyAddon:SetHeight(400)
MyAddon:SetPoint("CENTER",UIParent)
MyAddon:EnableMouse(true)
MyAddon:SetMovable(true)
MyAddon:RegisterForDrag("LeftButton")
MyAddon:SetScript("OnDragStart", function(self) self:StartMoving() end)
MyAddon:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
MyAddon:SetFrameStrata("FULLSCREEN_DIALOG")

local button = CreateFrame("button","MyAddonButton", MyAddon, "UIPanelButtonTemplate")
button:SetHeight(24)
button:SetWidth(60)
button:SetPoint("BOTTOM", MyAddon, "BOTTOM", 0, 10)
button:SetText("Close")
button:SetScript("OnClick", function(self) PlaySound("igMainMenuOption") self:GetParent():Hide() end)
http://www.wowwiki.com/Widget_API
http://www.wowwiki.com/Widget_Handlers

Those two links will be very helpful resources. Basically your SetScript is like the <Scripts> in XML code.

Edit: http://home.blarg.net/~tyroney/wow/uitutorial/ That's a guide I used when I was first starting out with creating visible frames. It's nice because it shows both the XML and lua way of going about creating frames.

Last edited by Freki : 08-03-08 at 04:56 PM. Reason: addition
  Reply With Quote