View Single Post
12-06-20, 10:36 PM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Scroll Frame Buttons not visible

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:
  1. local function updateDeathKnightSpellList()
  2.     FauxScrollFrame_Update(
  3.         DeathKnightScrollFrame,
  4.         #SpellChatGlobalTable1,
  5.         NumberList.scrollButtonNumber,
  6.         NumberList.scrollButtonWidth
  7.     )
  8.     for index = 1, NumberList.scrollButtonNumber do
  9.         local offset = index + FauxScrollFrame_GetOffset(DeathKnightScrollFrame)
  10.         local button = DeathKnightScrollFrame.buttons[index]
  11.         button.index = offset
  12.         if offset <= #SpellChatGlobalTable1 then
  13.             button:SetText(SpellChatGlobalTable1[offset])
  14.             button:Show()
  15.         else
  16.             button:Hide()
  17.         end
  18.     end
  19. end

And my final scroll frames;
Lua Code:
  1. local DeathKnightScrollParent = CreateFrame("Frame", "DeathKnightScrollParent", DeathKnightFrame, "BackdropTemplate", "TooltipBorderedFrameTemplate")
  2. DeathKnightScrollParent:SetBackdrop(
  3.     {
  4.         bgFile = nil,
  5.         insets = nil,
  6.         tileSize = nil,
  7.         tile = false,
  8.         edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
  9.         edgeSize = NumberList.edgeSize
  10.     }
  11. )
  12. DeathKnightScrollParent:SetBackdropBorderColor(unpack(ColourList.deathKnight))
  13. DeathKnightScrollParent:SetSize(NumberList.scrollFrameWidth, NumberList.scrollFrameHeight)
  14. DeathKnightScrollParent:SetPoint("TOP", DeathKnightFrameaddSpellButton, "BOTTOM", 0, -5)
  15.  
  16. local DeathKnightScrollFrame =
  17.     CreateFrame("ScrollFrame", "DeathKnightScrollFrame", DeathKnightScrollParent, "FauxScrollFrameTemplate")
  18. DeathKnightScrollFrame:SetPoint("TOPLEFT", 0, -8)
  19. DeathKnightScrollFrame:SetPoint("BOTTOMRIGHT", -30, 8)
  20. DeathKnightScrollFrame:SetScript(
  21.     "OnVerticalScroll",
  22.     function(self, offset)
  23.         FauxScrollFrame_OnVerticalScroll(self, offset, NumberList.scrollButtonHeight, updateDeathKnightSpellList)
  24.     end
  25. )
  26.  
  27. DeathKnightScrollFrame.buttons = {}
  28. for index = 1, NumberList.scrollButtonNumber do
  29.     DeathKnightScrollFrame.buttons[index] =
  30.         CreateFrame("Button", "btn" .. index, DeathKnightScrollParent, "OptionsListButtonTemplate")
  31.     local button = DeathKnightScrollFrame.buttons[index]
  32.     button:SetSize(NumberList.scrollFrameWidth, NumberList.scrollButtonHeight)
  33.     button:SetPoint("TOPLEFT", 8, -(index - 1) * NumberList.scrollButtonHeight - 8)
  34.     button:SetScript(
  35.         "OnClick",
  36.         function(self)
  37.             print("Test Print -  " .. SpellChatGlobalTable1[self.index])
  38.         end
  39.     )
  40. end

Here is a link to the scroll frame example that I have been referencing.

Thanks to all for your suggestions and help.

Cheers
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz

Last edited by Walkerbo : 12-11-20 at 03:13 AM.
  Reply With Quote