Thread Tools Display Modes
07-15-10, 04:24 AM   #1
hairy_palms
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 25
ScrollFrames make me sad :(

so ideally i wanted to make a scroll frame for a regular frame, i thought by reading the API it should work like this

Code:
local Parentpanel = CreateFrame("Frame", "Parentpanel", UIParent)
Parentpanel:SetPoint('CENTER', UIParent, 'CENTER', 0, 1)
Parentpanel:SetWidth(288)
Parentpanel:SetHeight(288)
for i = 1, 30 do
	local name, title, notes, enabled, loadable, reason, security = GetAddOnInfo(i)
	Parentpanel:CreateFontString("Childlist"..i, 'OVERLAY')
	_G["Childlist"..i]:SetPoint('TOPLEFT', Addonpanel, 'TOPLEFT', 10, -28*i)
	_G["Childlist"..i]:SetFont("Fonts\\ARIALN.ttf", 12)
	_G["Childlist"..i]:SetWidth(236)
	_G["Childlist"..i]:SetHeight(28)
	_G["Childlist"..i]:SetJustifyH('LEFT')
	_G["Childlist"..i]:SetText(title)		
end
local scrollArea = CreateFrame("ScrollFrame", "Scroller", UIParent, "UIPanelScrollFrameTemplate")
scrollArea:SetPoint("TOPLEFT", Parentpanel, "TOPLEFT", 8, -30)
scrollArea:SetPoint("BOTTOMRIGHT", Parentpanel, "BOTTOMRIGHT", -30, 8)
scrollArea:SetScrollChild(Parentpanel)
i was expecting it to create a scrollbar to scroll through the list of fontstrings,
any idea where ive gone wrong?

Last edited by hairy_palms : 07-15-10 at 04:27 AM.
  Reply With Quote
07-19-10, 11:04 AM   #2
ckaotik
A Fallenroot Satyr
 
ckaotik's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 29
Hrm. First of all, what is Addonpanel? You should anchor your fontstrings to the scrollframe child (Parentpanel in your case). Also, any reason for a 10 pixel x-offset?
I'd use it somewhat like this:
Code:
-- create the scroll frame
local scrollArea = CreateFrame("ScrollFrame", "Scroller", UIParent, "UIPanelScrollFrameTemplate")
scrollArea:SetPoint("TOPLEFT", Parentpanel, "TOPLEFT", 8, -30)
scrollArea:SetPoint("BOTTOMRIGHT", Parentpanel, "BOTTOMRIGHT", -30, 8)

-- create the scroll frame content
local Parentpanel = CreateFrame("Frame", "Parentpanel", scrollArea) -- don't know if you need to anchor it this way, but it works for me
scrollArea:SetScrollChild(Parentpanel)
Parentpanel:SetPoint("CENTER", UIParent, "CENTER", 0, 1)
Parentpanel:SetWidth(288)
Parentpanel:SetHeight(288)
for i = 1, 30 do
    local name, title, notes, enabled, loadable, reason, security = GetAddOnInfo(i)
    local addonText = Parentpanel:CreateFontString("Childlist"..i, 'OVERLAY')
    if i == 1 then
        addonText:SetPoint("TOPLEFT", Parentpanel)  -- anchors the first string, parent should be the content frame
    else
        addonText:SetPoint("TOPLEFT", _G["Childlist"..i-1], "BOTTOMLEFT")   -- anchors any following fontstrings below the previous one
    end
    addonText:SetFont("Fonts\\ARIALN.ttf", 12)
    addonText:SetWidth(236)
    addonText:SetHeight(28)
    addonText:SetJustifyH("LEFT")
    addonText:SetText(title)		
end
No guarantees and probably not the prettiest solution ... but I hope it helps
__________________
It all starts to make a creepy kind of sense. Avatar
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » ScrollFrames make me sad :(


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