WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Scroll Frame Buttons not visible (https://www.wowinterface.com/forums/showthread.php?t=58440)

Walkerbo 12-06-20 10:36 PM

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

Zax 12-07-20 01:40 AM

In this case, I would try first to add this debug line before "SetText()" at line 7:
Code:

print("index=", index, "offset=", offset, "SpellChatGlobalTable1[offset]=", SpellChatGlobalTable1[offset])
Don't know if it will help.

Walkerbo 12-07-20 08:26 PM

Just like I said there was a total small thing that prevented that buttons displaying.

In the update function I tried to update the scrollFrame which was not actually a frame in my code, I replaced it with the correct DeathKnightFrameScrollChild frame and now the buttons display.

However, I still have not been able to get the scroll frame to scroll.

I have been checking out other addons to see how they scroll without any success, so any further help would be great.


@Zax your suggestion of adding in a debug print does help, it is far too often that I could probably identify problems much earlier if I simply added debug prints :)

Zax 12-08-20 01:22 AM

I recently used this tutorial and it works:
https://wow.gamepedia.com/Making_a_s...lFrameTemplate

Though I had to replace:
Code:

FauxScrollFrame_Update(MyModScrollBar,50,5,16);
with
Code:

FauxScrollFrame_Update(MyModScrollBar,50,5,16, nil, nil, nil, nil, nil, nil, true);

Walkerbo 12-08-20 11:51 PM

Hi Zax

Thanks for that, I have tried adding all of the elements however that change had no effect.

I have not got the scroll frame working properly.
I can do a manual scroll by grabbing the scroll button and dragging.
But note the manual scrolls way beyond the last button which is also something that should not happen.

So I am still stuck on this one.

Here is an updated gif showing what is happening.

I really cannot see how this doesn't work, and it has got me banging my head against the desk.

Xrystal 12-09-20 01:56 AM

I have yet to identify the cause of the overscrolling myself. Likely a number misrepresented somewhere that is telling it that there are more entries.

Walkerbo 12-10-20 11:20 PM

Hi Xrystal

I have got some of this working.
In my update function, I made the variables at line 9 & 10 local.
In my frame code, I made the variable at line 31 local.

So the last issue I have left is that I can still scroll beyond the end of the list of buttons.

I have updated my OP to reflect the current status of my issue. :)

Walkerbo 12-11-20 03:16 AM

Whoot finally got it solved.

I had to make the step value the same as the button height.

I have edited the OP so all searching can see it first up.

Cheers all


All times are GMT -6. The time now is 09:33 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI