Originally Posted by Fizzlemizz
Something to look at and play with. A function to uniformly create all sub-frames (buttons in this case) with the return value being stored in a table attached to the main frame. Not the only way.
Lua Code:
local function CreateSubFrame(self) local f = CreateFrame("Button", "$parentSUBFRAME"..#self.SubFrames+1, self) f:SetSize(self:GetSize()) f.texture = f:CreateTexture("ARTWORK") f.texture:SetAllPoints() f.texture:SetTexture("Interface/BUTTONS/WHITE8X8") f.texture:SetVertexColor(0.3, 0.3, 0.3, 0.5) f.text = f:CreateFontString(nil, "OVERLAY", "GameFontNormal") f.text:SetPoint("CENTER") f.text:SetText(f:GetName()) local p if #self.SubFrames == 0 then p = self else p = self.SubFrames[#self.SubFrames] end f:SetPoint("TOP", p, "BOTTOM", 0, -5) f:SetScript("OnEnter", function(self) f.texture:SetVertexColor(0.6, 0.6, 0.6, 0.5) end) f:SetScript("OnLeave", function(self) f.texture:SetVertexColor(0.3, 0.3, 0.3, 0.5) end) f:SetScript("OnClick", function(self) print(self:GetName().." Clicked!!!!") end) return f end local mainWindow = CreateFrame("Frame", "wille480DragFrame", UIParent) -- The main window (Orange color) mainWindow:SetSize(200, 20) mainWindow:SetPoint("CENTER") mainWindow.SubFrames = {} for i= 1, 5 do tinsert(mainWindow.SubFrames, CreateSubFrame(mainWindow)) end
Frame names are global so you should try and make them unique, hence the addition of "wille480" to "DragFrame"
|
Wow, nice solution! Tweaked it abit for my likeing =) . Appriciate the help, kinda new to addon programming, made an addon before "HelyaAssist" but trying to learn a new skill as university times are short now! ty for help