Searching on the web I read the template "FauxScrollFrameTemplate" is now obsolete, you confirm? I have followed the advice of
this page. But now I have two problems:
- How do I put the slider into the frame? In this picture appears outside of him?
- Because the method does not work?
Here is the code:
Lua Code:
--parent frame
local frame = CreateFrame("Frame", "MyFrame", UIParent)
frame:SetSize(200, 320)
frame:SetPoint("CENTER")
local texture = frame:CreateTexture()
texture:SetAllPoints()
texture:SetTexture(1,1,1,1)
frame.background = texture
--scrollframe
scrollframe = CreateFrame("ScrollFrame", nil, frame)
scrollframe:SetPoint("TOPLEFT", 6, -8)
scrollframe:SetPoint("BOTTOMRIGHT", -30, 8)
scrollframe:EnableMouse(true)
scrollframe:EnableMouseWheel(true)
local texture = scrollframe:CreateTexture()
texture:SetAllPoints()
frame.scrollframe = scrollframe
--scrollbar
scrollbar = CreateFrame("Slider", nil, scrollframe, "UIPanelScrollBarTemplate")
scrollbar:SetPoint("TOPLEFT", frame, "TOPRIGHT", 6, -16)
scrollbar:SetPoint("BOTTOMLEFT", frame, "BOTTOMRIGHT", 6, 16)
scrollbar:SetMinMaxValues(0, 320)
scrollbar:SetValueStep(16)
scrollbar.scrollStep = 16
scrollbar:SetValue(0)
scrollbar:SetWidth(29)
scrollbar:EnableMouse(true)
scrollbar:EnableMouseWheel(true)
scrollframe.ScrollBar = scrollbar
scrollbar:SetScript("OnValueChanged",
function (self, value)
self:GetParent():SetVerticalScroll(value)
end)
scrollbar:SetScript("OnMouseWheel", function(self, delta)
delta = ((delta * scrollbar:GetValueStep())) * -1
local value = scrollbar:GetValue()
scrollbar:SetValue(value + delta)
if ((value + delta) > 0) then self:GetParent():SetVerticalScroll(value + delta) end
end)
local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
scrollbg:SetAllPoints(scrollbar)
frame.scrollbar = scrollbar
scrollbar:EnableMouse(false)
scrollframe:SetScript("OnMouseWheel", function(self, delta)
delta = ((delta * scrollbar:GetValueStep())) * -1
local value = scrollbar:GetValue()
scrollbar:SetValue(value + delta)
if ((value + delta) > 0) then self:SetVerticalScroll(value + delta) end
end)
--content frame
local content = CreateFrame("Button", nil, scrollframe)
content:SetSize(128, 16)
local texture = content:CreateTexture()
texture:SetAllPoints()
texture:SetTexture(1,0,0,1)
local text = content:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
text:SetPoint("CENTER", content)
content.text = text
text:SetText("content")
scrollframe.content = content
scrollframe:SetScrollChild(content)