here is what i am currently using (pick and chose the sections you want)
Code:
local addonname, addon = ...
local backdrop = {
bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 16,
insets = { left = 4, right = 3, top = 4, bottom = 3 }
}
local function ScrollframeOnSizeChanged(frame, width, height)
frame:GetScrollChild():SetWidth(width)
end
local counter = 0
local function Constructor()
counter = counter + 1
local box = CreateFrame("frame", nil, UIParent)
box:SetWidth(100)
box:SetHeight(100)
box:SetBackdrop(backdrop)
box:SetBackdropColor(0, 0, 0)
box:SetBackdropBorderColor(0.4, 0.4, 0.4)
local scroll = CreateFrame("ScrollFrame", addonname.."ScrollFrame"..counter, box, "UIPanelScrollFrameTemplate")
scroll:SetPoint("TOPLEFT", box, 5, -5)
scroll:SetPoint("BOTTOMRIGHT", box, -26, 4)
scroll:EnableMouse(true)
box.scroll = scroll
box.scrollbar = _G[addonname.."ScrollFrame"..counter.."ScrollBar"]
local child = CreateFrame("frame", addonname.."ScrollFramechild"..counter, scroll)
child:SetWidth(scroll:GetWidth())
box.child = child
scroll:SetScrollChild(child)
scroll:SetScript("OnSizeChanged", ScrollframeOnSizeChanged)
return box
end
local function Neutralizer(box)
box:SetParent(UIParent)
box.scrollbar:SetValue(0)
box:Hide()
end
addon:RegisterWidget("scrollframe", Constructor, Neutralizer)
important things to look at is the local scroll and the local child (frame is just for background and better positioning)
then all you have to do is change the height of the child and the rest gets set by the template blizzard gives us (everything you want scrolled needs to be anchored and parented to he child frame)
If you go the route of the template then you need to give the frame a name otherwise it will simply toss errors at you.