Originally Posted by Fizzlemizz
One fairly basic approach depending on knowing the total number of buttons ahead of time and the gridFrame size being absolute.
Lua Code:
local gridFrame = CreateFrame("Frame", "DragFrame2", UIParent) gridFrame:SetMovable(true) gridFrame:EnableMouse(true) gridFrame:RegisterForDrag("LeftButton") gridFrame:SetScript("OnDragStart", gridFrame.StartMoving) gridFrame:SetScript("OnDragStop", gridFrame.StopMovingOrSizing) -- The code below makes the frame visible, and is not necessary to enable dragging. gridFrame:SetPoint("CENTER"); gridFrame:SetWidth(300); gridFrame:SetHeight(300); local gridFrameTexture = gridFrame:CreateTexture("ARTWORK"); gridFrameTexture:SetAllPoints(); gridFrameTexture:SetColorTexture(0.89,0.44,0.1, 0.5) local last = gridFrame local count = 8 local height = gridFrame:GetHeight()/count local point = "TOPLEFT" -- SubFrame for i=1, count do local subFrame = CreateFrame("Button", "subFrame"..i, gridFrame) subFrame:SetSize(300, height); subFrame:SetHighlightTexture(136477) subFrame:SetPoint("TOPLEFT", last, point) last = subFrame if i == 1 then point = "BOTTOMLEFT" end local texture = subFrame:CreateTexture("ARTWORK") texture:SetAllPoints() texture:SetColorTexture(1,0,0.1, 1) local fontString = subFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal") fontString:SetPoint("CENTER") fontString:SetText("hej") end
|
Ah okay! I do not know the amount of frames created ahead of time sadly. I posted a question about this before but all my work got deleted and i have to start all over..
I did this for now and seems to be working
Lua Code:
function CreateSubFrame(window, player)
local aidsFrame = CreateFrame("Button", "subFrame", UIParent, "SecureHandlerClickTemplate")
aidsFrame:SetWidth(300)
aidsFrame:SetHeight(50)
local count = 0
for elements in pairs(window) do
count = count + 1
end
aidsFrame:SetPoint("TOP", mainWindow, 0, count * -50)
local aidsTexture = aidsFrame:CreateTexture("ARTWORK")
aidsTexture:SetAllPoints()
aidsTexture:SetColorTexture(1.0, 0, 0, 1)
return aidsFrame
end
mainWindow = CreateFrame("Frame", "wille480DragFrame", gridFrame)
mainWindow:SetSize(300, 300)
mainWindow:SetPoint("TOP")
mainWindow.SubFrames = {}
mainWindowTexture = mainWindow:CreateTexture("ARTWORK")
mainWindowTexture:SetAllPoints();