Hi all
Whoot got it all working.
The major things I learnt to get this working;
Make sure that you are calling the correct frame, even if it looks the same, (I had an extra space).
Make sure all variables are local, even if they are in a local function.
Make the step value that same as the button height, this ensures the scroll stops at the maximum of the list.
This is my final update code chunk;
Lua Code:
local function updateDeathKnightSpellList()
FauxScrollFrame_Update(
DeathKnightScrollFrame,
#SpellChatGlobalTable1,
NumberList.scrollButtonNumber,
NumberList.scrollButtonWidth
)
for index = 1, NumberList.scrollButtonNumber do
local offset = index + FauxScrollFrame_GetOffset(DeathKnightScrollFrame)
local button = DeathKnightScrollFrame.buttons[index]
button.index = offset
if offset <= #SpellChatGlobalTable1 then
button:SetText(SpellChatGlobalTable1[offset])
button:Show()
else
button:Hide()
end
end
end
And my final scroll frames;
Lua Code:
local DeathKnightScrollParent = CreateFrame("Frame", "DeathKnightScrollParent", DeathKnightFrame, "BackdropTemplate", "TooltipBorderedFrameTemplate")
DeathKnightScrollParent:SetBackdrop(
{
bgFile = nil,
insets = nil,
tileSize = nil,
tile = false,
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
edgeSize = NumberList.edgeSize
}
)
DeathKnightScrollParent:SetBackdropBorderColor(unpack(ColourList.deathKnight))
DeathKnightScrollParent:SetSize(NumberList.scrollFrameWidth, NumberList.scrollFrameHeight)
DeathKnightScrollParent:SetPoint("TOP", DeathKnightFrameaddSpellButton, "BOTTOM", 0, -5)
local DeathKnightScrollFrame =
CreateFrame("ScrollFrame", "DeathKnightScrollFrame", DeathKnightScrollParent, "FauxScrollFrameTemplate")
DeathKnightScrollFrame:SetPoint("TOPLEFT", 0, -8)
DeathKnightScrollFrame:SetPoint("BOTTOMRIGHT", -30, 8)
DeathKnightScrollFrame:SetScript(
"OnVerticalScroll",
function(self, offset)
FauxScrollFrame_OnVerticalScroll(self, offset, NumberList.scrollButtonHeight, updateDeathKnightSpellList)
end
)
DeathKnightScrollFrame.buttons = {}
for index = 1, NumberList.scrollButtonNumber do
DeathKnightScrollFrame.buttons[index] =
CreateFrame("Button", "btn" .. index, DeathKnightScrollParent, "OptionsListButtonTemplate")
local button = DeathKnightScrollFrame.buttons[index]
button:SetSize(NumberList.scrollFrameWidth, NumberList.scrollButtonHeight)
button:SetPoint("TOPLEFT", 8, -(index - 1) * NumberList.scrollButtonHeight - 8)
button:SetScript(
"OnClick",
function(self)
print("Test Print - " .. SpellChatGlobalTable1[self.index])
end
)
end
Here is a link to the scroll frame example that I have been referencing.
Thanks to all for your suggestions and help.
Cheers