01-08-08, 06:31 PM | #1 |
Help With FauxScrollFrame
I'm trying to experiment with FauxScrollFrames but I cant get it working right. When it first loads the buttons have the "Test <RandomNumber>" text on them but it disappears every time I scroll.
I started out with code based on WoWWiki HOWTOMake a Scrollable List Using FauxScrollFrameTemplate and it worked at first. But I'm renaming everything so it makes sense more when I add everything else onto the frame. I've started over already and got the same result. I fairly certain I haven't left any of the old variables in there. When you 'scroll' all it does is reset the text on the 5 buttons right? so why would it work when it initially loads them but not after each scroll? Anyway and help, tips, or pointers you can give would be greatly appreciated. Thanks in advance. tdtKBs.toc Code:
## X-AutoGenerated: true ## X-GeneratorComment: Basic project properties and project files will be automatically added during deployment. Properties added by the user will be copied without changes. ## Interface: 20300 ## Title: tdtKBs ## Notes: Basic WoW Addon ## Version: 1.0 tdtKBs.xml tdtKBs.lua Code:
<Ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.blizzard.com/wow/ui/"> <Script file="tdtKBs.lua" /> <Button name="tdtKBsEntryTemplate" virtual="true"> <Size> <AbsDimension x="150" y="16" /> </Size> <NormalFont inherits="GameFontHighlight" justifyH="LEFT" /> </Button> <Frame name="tdtKBs" parent="UIParent" toplevel="true" movable="true" enableMouse="true"> <Size> <AbsDimension x="350" y="475" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset> <AbsDimension x="120" y="-66" /> </Offset> </Anchor> </Anchors> <Scripts> <OnLoad> tdtKBs_OnLoad() </OnLoad> </Scripts> <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true"> <BackgroundInsets> <AbsInset left="11" right="12" top="12" bottom="11" /> </BackgroundInsets> <TileSize> <AbsValue val="32" /> </TileSize> <EdgeSize> <AbsValue val="32" /> </EdgeSize> </Backdrop> <Frames> <ScrollFrame name="tdtKBsScrollBar" inherits="FauxScrollFrameTemplate" hidden="true"> <Size x="282" y="111" /> <Anchors> <Anchor point="TOPLEFT"> <Offset> <AbsDimension x="25" y="-136" /> </Offset> </Anchor> <Anchor point="BOTTOMRIGHT"> <Offset> <AbsDimension x="-43" y="228" /> </Offset> </Anchor> </Anchors> <Scripts> <OnVerticalScroll> FauxScrollFrame_OnVerticalScroll(16, tdtKBsScrollBar_Update); </OnVerticalScroll> <OnShow> tdtKBsScrollBar_Update() </OnShow> </Scripts> </ScrollFrame> <Button name="tdtKBsScrollEntry1" inherits="tdtKBsEntryTemplate" text="tdtKBsScrollEntry1"> <Size> <AbsDimension x="250" y="16" /> </Size> <Anchors> <Anchor point="TOPLEFT" relativeTo="tdtKBsScrollBar" relativePoint="TOPLEFT"> <Offset> <AbsDimension x="3" y="-3" /> </Offset> </Anchor> </Anchors> </Button> <Button name="tdtKBsScrollEntry2" inherits="tdtKBsEntryTemplate" text="tdtKBsScrollEntry2"> <Size> <AbsDimension x="250" y="16" /> </Size> <Anchors> <Anchor point="TOPLEFT" relativeTo="tdtKBsScrollEntry1" relativePoint="BOTTOMLEFT" /> </Anchors> </Button> <Button name="tdtKBsScrollEntry3" inherits="tdtKBsEntryTemplate" text="tdtKBsScrollEntry3"> <Size> <AbsDimension x="250" y="16" /> </Size> <Anchors> <Anchor point="TOPLEFT" relativeTo="tdtKBsScrollEntry2" relativePoint="BOTTOMLEFT" /> </Anchors> </Button> <Button name="tdtKBsScrollEntry4" inherits="tdtKBsEntryTemplate" text="tdtKBsScrollEntry4"> <Size> <AbsDimension x="250" y="16" /> </Size> <Anchors> <Anchor point="TOPLEFT" relativeTo="tdtKBsScrollEntry3" relativePoint="BOTTOMLEFT" /> </Anchors> </Button> <Button name="tdtKBsScrollEntry5" inherits="tdtKBsEntryTemplate" text="tdtKBsScrollEntry5"> <Size> <AbsDimension x="250" y="16" /> </Size> <Anchors> <Anchor point="TOPLEFT" relativeTo="tdtKBsScrollEntry4" relativePoint="BOTTOMLEFT" /> </Anchors> </Button> </Frames> </Frame> </Ui> Code:
ChatData = {} function tdtKBs_OnLoad() for i=1,50 do ChatData[i] = "Test "..math.random(100) end tdtKBsScrollBar:Show() end function tdtKBsScrollBar_Update() local line; -- 1 through 5 of our window to scroll local lineplusoffset; -- an index into our data calculated from the scroll offset FauxScrollFrame_Update(tdtKBsScrollBar,50,5,16); for line=1,5 do lineplusoffset = line + FauxScrollFrame_GetOffset(tdtKBsScrollBar); if lineplusoffset <= 50 then getglobal("tdtKBsScrollEntry"..line):SetText(ChatData[lineplusoffset]); getglobal("tdtKBsScrollEntry"..line):Show(); else getglobal("tdtKBsScrollEntry"..line):Hide(); end end end |
|
WoWInterface » Developer Discussions » Lua/XML Help » Help With FauxScrollFrame |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|