05-27-09, 02:07 AM | #1 |
Scroll Frames...*Sigh*
I've been reading forums and looking at code from other authors for the last couple evenings trying to wrap my brain around this.
I've look at code that uses "FauxScrollFrameTemplate" but from what I read it maybe over kill for what I need. So I found this thread: http://www.wowinterface.com/forums/s...ad.php?t=17814 which Mera gave a really good example. Since I've been search for examples of how to populate the scrollframe with data. Where each line item was a button with 3 columns that fired off other methods on left and right button click. I would like to stay with creating the scrollframe using lua script and not xml. Help?!? |
|
05-27-09, 05:56 AM | #2 |
You just need to have some child buttons inside your scroll buttons.
TBH I think that this is the one situation where there's really no tenable argument against using a little XML, since you can't create templates in Lua. However, if you really wanted to you could create a function that created a frame and then three child buttons for you and just call that each time. For example, my addon GOM has a scrollframe with unclickable player names, which each have a checkbox to the left of them. It would be pretty easy to expand this template to have three buttons instead of the checkbox and/or convert this to a Lua function instead of an XML virtual button: Code:
<Button name="GOMaticScrollFrameCheckButtonTemplate" virtual="true"> <Size> <AbsDimension x="200" y="16"/> </Size> <Frames> <Frame name="$parentData" setAllPoints="true"> <Layers> <Layer level="BORDER"> <FontString name="$parentLabel" inherits="GameFontNormal"> <Anchor point="TOPLEFT"> <AbsDimension x="5" y="-2"/> </Anchor> </FontString> </Layer> </Layers> </Frame> <CheckButton name="$parentCheck" inherits="OptionsCheckButtonTemplate"> <Size> <AbsDimension x="25" y="25"/> </Size> <Anchors> <Anchor point="TOPLEFT" relativePoint="TOPLEFT" relativeTo="$parentData"> <Offset> <AbsDimension x="0" y="2"/> </Offset> </Anchor> </Anchors> <Scripts> <OnClick> GrOM.AddOrRemoveSync(self) </OnClick> </Scripts> </CheckButton> </Frames> </Button> Last edited by Akryn : 05-27-09 at 06:05 AM. |
|
05-28-09, 01:17 AM | #3 |
Ok I got some where but I'm still getting an error..
Code:
local function scrollUpdate() local list = db.events; local line, lineplusoffset; FauxScrollFrame_Update(frames.scroll,50,#list,20) for line = 1, #list do lineplusoffset = line + FauxScrollFrame_GetOffset(frames.scroll) if lineplusoffset < 50 then _G[MODNAME.."ScrollButton"..line]:SetText(list[lineplusoffset].set) _G[MODNAME.."ScrollButton"..line]:Show() else _G[MODNAME.."ScrollButton"..line]:Hide() end end end function addon:CreateScrollFrame() frames.scroll = CreateFrame("ScrollFrame", MODNAME.."ScrollFrame", UIParent, "FauxScrollFrameTemplate"); frames.scroll:SetWidth(118) frames.scroll:SetHeight(180) frames.scroll:SetPoint("CENTER", "UIParent", "CENTER", 0, 0) frames.scroll:SetBackdrop({ bgFile="", edgeFile="Interface\\Tooltips\\UI-Tooltip-Border", tile="true", tileSize= 32, edgeSize=10, insets = {left=5, right=5, top=5, bottom=5} }) frames.scroll:SetBackdropBorderColor(0,.5,0,1) frames.scroll:SetScript("OnVerticalScroll", function(self, offset) FauxScrollFrame_OnVerticalScroll(self, offset, 20, scrollUpdate) end) frames.scroll:SetScript("OnShow", scrollUpdate); for i = 1,#db.events do local b if i == 1 then b = CreateFrame("Button", MODNAME.."ScrollButton"..i, frames.scroll) b:SetPoint("TOPLEFT", 2,-5) b:SetText("Button 1") else b = CreateFrame("Button", MODNAME.."ScrollButton"..i, _G[MODNAME.."ScrollButton"..(i-1)]) b:SetPoint("TOPLEFT", _G[MODNAME.."ScrollButton"..(i-1)], "BOTTOMLEFT", 0, 4) b:SetText("Button "..i) end b:SetNormalFontObject("GameFontNormalSmall") b:RegisterForClicks("LeftButtonUp") b:SetWidth(114) b:SetHeight(20) b:SetBackdrop({ bgFile = "Interface\\CHATFRAME\\CHATFRAMEBACKGROUND", edgeFile = "", tile = "true", tileSize = 32, edgeSize = 10, insets = {left = 3, right = 3, top = 3, bottom = 3} }) b:SetBackdropColor(1,1,1,1) b:SetScript("OnClick", function() self:Print("Button Onclick!"); end ) end end core.lua:242: attempt to index field '?' (a nil value) Line 242 is _G[MODNAME.."ScrollButton"..line]:SetText(list[lineplusoffset].set) Which probably means that its trying to get data from an index in an array that doesn't exist. And this only occurs when I'm scrolling the verticale scroll bar. My Data set looks like this: Code:
["events"] = { { ["set"] = "DPS", ["event"] = "PVP", ["talent"] = "Primary", }, -- [1] { ["set"] = "Lance", ["event"] = "Mounted", ["talent"] = "Primary", }, -- [2] { ["set"] = "Tank", ["event"] = "City", ["talent"] = "Primary", }, -- [3] { ["event"] = "Evocation", ["set"] = "DPS", }, -- [4] }, Last edited by Tymesink : 05-28-09 at 01:20 AM. |
|
WoWInterface » Developer Discussions » General Authoring Discussion » Scroll Frames...*Sigh* |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|