I am doing good progress
The code finally is displaying something :-)
Lua Code:
local NUM_BUTTONS = 8
local BUTTON_HEIGHT = 20
local BUTTON_WIDTH = 96
local list = {"aaaa","bbbbb","cccccc","ddddddd","eeeeee","ffffff","gggggg","hhhhh"}
local buttons = {}
local function update(self)
local numItems = #list
print ("DEBUG: nr. items " .. numItems)
FauxScrollFrame_Update(self, numItems, NUM_BUTTONS, BUTTON_HEIGHT)
local offset = FauxScrollFrame_GetOffset(self)
for line = 1, NUM_BUTTONS do
local lineplusoffset = line + offset
local button = buttons[line]
if lineplusoffset > numItems then
button:Hide()
else
button:SetText(list[lineplusoffset])
button:Show()
end
end
end
local scrollFrame = CreateFrame("ScrollFrame", "MyFirstNotReallyScrollFrame", UIParent, "FauxScrollFrameTemplate")
scrollFrame:SetWidth(BUTTON_WIDTH)
scrollFrame:SetHeight(BUTTON_HEIGHT*6)
scrollFrame:SetPoint("CENTER",UIParent)
scrollFrame:EnableMouse(true)
scrollFrame:SetMovable(true)
scrollFrame:RegisterForDrag("LeftButton")
scrollFrame:SetScript("OnDragStart", function(self) self:StartMoving() end)
scrollFrame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
scrollFrame:Show()
scrollFrame:SetClampedToScreen(true)
scrollFrame:SetScript("OnVerticalScroll", function(self, offset)
FauxScrollFrame_OnVerticalScroll(self, offset, BUTTON_HEIGHT, update)
end)
for i = 1, NUM_BUTTONS do
local button = CreateFrame("Button", nil, scrollFrame:GetParent())
if i == 1 then
button:SetPoint("TOP", scrollFrame)
else
button:SetPoint("TOP", buttons[i - 1], "BOTTOM")
end
button:SetNormalFontObject("GameFontNormal")
button:SetSize(BUTTON_WIDTH, BUTTON_HEIGHT)
button:SetText(list[i])
buttons[i] = button
end
-- enabling the last line will make the slidebar disappears.
-- print ("DEBUG: Force updating")
-- update(scrollFrame)
Now I get the scrollframe with sliders but it is wrong. You can check the picture to see...
It doesn't cover the out of scrollframe part nor it scrolls using the slide.
Other thing: If I enable the manual update of the frame (last line) the sliders will disappears (!??!) :-)
Thanks again for any inputs/clues/tips :-)