WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   ScrollFrames make me sad :( (https://www.wowinterface.com/forums/showthread.php?t=33959)

hairy_palms 07-15-10 04:24 AM

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?

ckaotik 07-19-10 11:04 AM

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 :)


All times are GMT -6. The time now is 04:01 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI