Thread Tools Display Modes
02-17-11, 12:23 AM   #1
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Scrolling frames.

Anyone have suggestions on where to start with making scrolling frames? Working on in game help system. trying to make two, the left fame with text buttons that are the various section titles when clicked on it would load the text for that header into the frame on the right. both frames would need to be scrollable.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
02-17-11, 10:35 AM   #2
kneeki
A Flamescale Wyrmkin
 
kneeki's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 134
Pretty sure there is a WoWAce Lib which helps with the creation of exactly this. Don't recall the name off hand though.
  Reply With Quote
02-17-11, 10:41 AM   #3
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Well it looks like dewdroplib has scroll frame templates in it but i cant find any decent documentation on it. Im using the optionsassist lib by vrul and the AceGUI lib's already which also has scroll frame templates in it but im not sure how to get my help window frame to use it lol.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
02-17-11, 11:12 AM   #4
yssaril
A Warpwood Thunder Caller
 
yssaril's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 96
here is what i am currently using (pick and chose the sections you want)

Code:
local addonname, addon = ...

local backdrop = {
	bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
	edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 16,
	insets = { left = 4, right = 3, top = 4, bottom = 3 }
}

local function ScrollframeOnSizeChanged(frame, width, height)
	frame:GetScrollChild():SetWidth(width)
end

local counter = 0
local function Constructor()
	counter = counter + 1

	local box = CreateFrame("frame", nil, UIParent)
		box:SetWidth(100)
		box:SetHeight(100)
		box:SetBackdrop(backdrop)
		box:SetBackdropColor(0, 0, 0)
		box:SetBackdropBorderColor(0.4, 0.4, 0.4)
	
	local scroll = CreateFrame("ScrollFrame", addonname.."ScrollFrame"..counter, box, "UIPanelScrollFrameTemplate")
		scroll:SetPoint("TOPLEFT", box, 5, -5)
		scroll:SetPoint("BOTTOMRIGHT", box, -26, 4)
		scroll:EnableMouse(true)
	box.scroll = scroll
	box.scrollbar = _G[addonname.."ScrollFrame"..counter.."ScrollBar"]
	
	local child = CreateFrame("frame", addonname.."ScrollFramechild"..counter, scroll)
		child:SetWidth(scroll:GetWidth())
	box.child = child
	
	scroll:SetScrollChild(child)
	scroll:SetScript("OnSizeChanged", ScrollframeOnSizeChanged)

	return box
end

local function Neutralizer(box)
	box:SetParent(UIParent)
	box.scrollbar:SetValue(0)
	box:Hide()
end

addon:RegisterWidget("scrollframe", Constructor, Neutralizer)
important things to look at is the local scroll and the local child (frame is just for background and better positioning)

then all you have to do is change the height of the child and the rest gets set by the template blizzard gives us (everything you want scrolled needs to be anchored and parented to he child frame)

If you go the route of the template then you need to give the frame a name otherwise it will simply toss errors at you.

Last edited by yssaril : 02-17-11 at 11:16 AM.
  Reply With Quote
02-17-11, 11:26 AM   #5
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
ooooo an all lua no library necessary version! exactly what i was looking for. I will play with this see if i can get it to work thank you!

Just looking at it... that register widget part? does the bliz api understand that or is that a function coming from elsewhere? what exactly does registerwidget do?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 02-17-11 at 11:34 AM.
  Reply With Quote
02-17-11, 11:43 AM   #6
yssaril
A Warpwood Thunder Caller
 
yssaril's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 96
Originally Posted by Grimsin View Post
ooooo an all lua no library necessary version! exactly what i was looking for. I will play with this see if i can get it to work thank you!

Just looking at it... that register widget part? does the bliz api understand that or is that a function coming from elsewhere? what exactly does registerwidget do?
its my own API sorry i created a small widget recycler so i can make widgets use them and then toss them back and reuse them

Recycler looks like this
Code:
local addonname, addon = ...

function addon:RegisterWidget(name, constructor, neutralizer)
	self.widgetconstructors = self.widgetconstructors or {}
	self.widgetneutalizers = self.widgetneutalizers or {}
	self.widgetconstructors[name] = constructor
	self.widgetneutalizers[name] = neutralizer
end

local pool = {}
function addon:GetWidget(name, parent)
	local widget
	if self.widgetconstructors[name] then
		if pool[name] and next(pool[name]) then
			widget = table.remove(pool[name])
		else
			widget = self.widgetconstructors[name]()
			_G[addonname.."Widgets"] = _G[addonname.."Widgets"] or {} --toss all widgets into _G but in their own table so we don't polute _G
			_G[addonname.."Widgets"][name] = _G[addonname.."Widgets"][name] or {}
			_G[addonname.."Widgets"][name][#_G[addonname.."Widgets"][name]+1] = widget
			widget.__name = name
		end
	else
		error("Invalid widget name: "..name)
	end
	if parent then
		widget:SetParent(parent)
	end
	return widget
end

function addon:ReturnWidget(widget)
	local name = widget.__name
	self.widgetneutalizers[name](widget)
	pool[name] = pool[name] or {}
	table.insert(pool[name], widget)
	return nil
end
  Reply With Quote
02-17-11, 11:56 AM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Here's one of my more simple versions of a scroll frame I've used in one of my mock up addons to play with stuff. It's loosely based on the scroll frame code I created for my ScrollingWatchFrame addon but literally just the bare bones.
frame is whatever container frame you want to use to confine the visual part of the scrolling area.
scrollFrame is the scrolling area itself which can be bigger than the container frame.
scrollChild is the frame you do all the work with and assign it to the scrollFrame as a child so that the scrollFrame's scrolling allows you to see parts for the scrollChild's frame.
scrollBar is a pointer to the built in scroll bar component of the base template UIPanelScrollFrameTemplate which handles most of the basic functionality.
scrollSize is a variable to hold the height I want the scrollFrame to be but I assume it could be similarly used as width if you have a horizontal scrollbar rather than a vertical one.

Code:
	frame.scrollSize = missingCount * 40
	
	frame.scrollFrame = CreateFrame( "ScrollFrame", "$parent_ScrollFrame", frame, "UIPanelScrollFrameTemplate" );
	frame.scrollFrame:SetHeight(frame:GetHeight())
	frame.scrollBar = _G[frame.scrollFrame:GetName() .. "ScrollBar"];
    frame.scrollFrame:SetWidth( frame:GetWidth());
	frame.scrollFrame:SetPoint( "TOPLEFT", 10, -30 );
	frame.scrollFrame:SetPoint( "BOTTOMRIGHT", -30, 10 );
	
    frame.scrollChild = CreateFrame( "Frame", "$parent_ScrollChild", frame.scrollFrame );
	frame.scrollChild:SetHeight( frame.scrollSize );
    frame.scrollChild:SetWidth( frame.scrollFrame:GetWidth() );
    frame.scrollChild:SetAllPoints( frame.scrollFrame );
    frame.scrollFrame:SetScrollChild( frame.scrollChild );
It's not brilliant but if you want to see something minimal to help you understand how it works it might be worth looking at. But yssaril's code is very useful to know too.
__________________
  Reply With Quote
02-18-11, 12:43 AM   #8
hankthetank
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 64
Lightbulb

The "real" scroll frame template (not the faux one) is pretty self-explanatory.

Create a scroll frame derived from UIPanelScrollFrameTemplate and a content host:

lua Code:
  1. local f = CreateFrame("Frame") -- Your window
  2. ...
  3. f.scroll = CreateFrame("ScrollFrame", "myScrollFrame", f, "UIPanelScrollFrameTemplate")
  4. --[[
  5.   Position and style the scrollframe. Here you could do things like...
  6.   _G["myScrollFrameScrollBarScrollUpButton"]:SetNormalTexture(....)
  7.   See http://wowprogramming.com/utils/xmlbrowser/diff/FrameXML/UIPanelTemplates.xml
  8. ]]
  9. f.content = CreateFrame("Frame", nil, f.scroll)
  10. f.content:SetSize(f.scroll:GetWidth(), 0) -- Vert scroll only (*)
  11. f.scroll:SetScrollChild(f.content)

*: If your main window / scroll frame layout is resizable and your scroll frame unidirectional make sure to resize the content host when the scroll frame's size changed:

lua Code:
  1. f.scroll:SetScript("OnSizeChanged", function(_, w, h) f.content:SetWidth(w) end)

After you fill your scroll child with content make sure to set the points

lua Code:
  1. local myHugeFontString = f.content:CreateFontString()
  2.  
  3. myHugeFontString:SetPoint("TOPLEFT")
  4. myHugeFontString:SetPoint("TOPRIGHT") -- Vert scroll only
  5. myHugeFontString:SetFont.....
  6. myHugeFontString:SetText(alotOfText)
  7.  
  8. -- Resize content area
  9. f.content:SetPoint("BOTTOM", myHugeFontString)

That's like 10 lines of code. Idk why you would need a library for this. And since your content is so static, you don't need to recycle anything neither. All you really do is

lua Code:
  1. aButtonInTheLeftScrollFrame:SetScript("OnClick", function()
  2.     myHeaderTextFontStringInTheRightScrollFrame:SetText(....)
  3.     myBodyTextFontStringInTheRightScrollFrame:SetText(....)
  4. end)

Last edited by hankthetank : 02-18-11 at 05:52 AM.
  Reply With Quote
02-18-11, 11:49 AM   #9
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
i got the scroll frames down that was easy... now im fighting with my old nemesis again... tables and creating lots of frames based on table entry's...

What im trying to do now is make it so that i add buttons and their corresponding big chunk of text within a table so i can add buttons and change text within the table and never mess with anything else again. So of course i need to have it set up the buttons in the left scrollframe according to number of table entry's... the tricky part starts to be when i try to later have it do the settext stuff...

my real problem lies within the use of names in the global space because i still seem to be confused about what doing something.something.something = something.something:createsomething(blahblahblah, itsname, blahblah) does and how come i cant make changes to the frame later by the name in the itsname location and can only use the something.something.something to call it again and when im forced to use the something.something.something is it possible to put variables into the .somethings somehow?

this is what i have it doesnt not work this way or at lest this is the chunk im playing with if i showed the whole thing you'd see lots of commented out stuff and nonsense from me trying to figure it out. You can see the table at the top. right now im just trying to get the text to show up and figure out what method of something.something = createsomething(name) i need to use in order to use the names later outside of that for statement... i did get it to work by writing out each button but... thats a pain and lots of unnecessary lines of code...
Obi-Vrul-Kanobi is prolly gonna show up and shake his head at me considering hes tried to explain this to me a few times lol.

lua Code:
  1. local HelpHeaders = {
  2.     ['General'] = 'blahblahgeneral',
  3.     ['Buttons'] = 'blahblahbuttons',
  4.     ['Frame Mover'] = 'blahblahmover',
  5.     ['Chat'] = 'blahblahchat',
  6.     ['Tooltips'] = 'blahblahtooltips',
  7.     ['Unit Frames'] = 'blahblahunitframes',
  8.     ['Backpack'] = 'blahblahbakpak',
  9.     ['DashBoard'] = 'blahblahdashboard',
  10.     ['HUD'] = 'blahblahhud',
  11.     ['Development'] = 'blahblahdevtools',
  12. }
  13.  
  14. local LeftScrollBar = CreateFrame("Frame", "LeftScrollBar", GUIHelpFrame)
  15. LeftScrollBar:SetPoint("TOPLEFT", GUIHelpFrame, "TOPLEFT", 0, 0)
  16. LeftScrollBar:SetHeight("440")
  17. LeftScrollBar:SetWidth("170")
  18.  
  19. LeftScrollBar.scrollSize = 600
  20. LeftScrollBar.scrollFrame = CreateFrame( "ScrollFrame", "$parent_ScrollFrame", LeftScrollBar, "UIPanelScrollFrameTemplate" );
  21. LeftScrollBar.scrollFrame:SetHeight(LeftScrollBar:GetHeight())
  22. LeftScrollBar.scrollBar = _G[LeftScrollBar.scrollFrame:GetName() .. "ScrollBar"];
  23. LeftScrollBar.scrollFrame:SetWidth( LeftScrollBar:GetWidth());
  24. LeftScrollBar.scrollFrame:SetPoint( "TOPLEFT", 10, -30 );
  25. LeftScrollBar.scrollFrame:SetPoint( "BOTTOMRIGHT", -30, 10 );
  26.  
  27. LeftScrollBar.scrollChild = CreateFrame( "Frame", "$parent_ScrollChild", LeftScrollBar.scrollFrame );
  28. LeftScrollBar.scrollChild:SetHeight( LeftScrollBar.scrollSize );
  29. LeftScrollBar.scrollChild:SetWidth( LeftScrollBar.scrollFrame:GetWidth() );
  30. LeftScrollBar.scrollChild:SetAllPoints( LeftScrollBar.scrollFrame );
  31. LeftScrollBar.scrollFrame:SetScrollChild( LeftScrollBar.scrollChild );
  32.  
  33. local RightScrollBar = CreateFrame("Frame", "RightScrollBar", GUIHelpFrame)
  34. RightScrollBar:SetPoint("TOPRIGHT", GUIHelpFrame, "TOPRIGHT", -50, 0)
  35. RightScrollBar:SetHeight("420")
  36. RightScrollBar:SetWidth("380")
  37. RightScrollBar.scrollSize = 600
  38.  
  39. RightScrollBar.scrollFrame = CreateFrame( "ScrollFrame", "$parent_ScrollFrame", RightScrollBar, "UIPanelScrollFrameTemplate" );
  40. RightScrollBar.scrollFrame:SetHeight(RightScrollBar:GetHeight())
  41. RightScrollBar.scrollBar = _G[RightScrollBar.scrollFrame:GetName() .. "ScrollBar"];
  42. RightScrollBar.scrollFrame:SetWidth( RightScrollBar:GetWidth());
  43. RightScrollBar.scrollFrame:SetPoint( "TOPRIGHT", 10, -30 );
  44. RightScrollBar.scrollFrame:SetPoint( "BOTTOMRIGHT", -30, 10 );
  45.  
  46. RightScrollBar.scrollChild = CreateFrame( "Frame", "$parent_ScrollChild", RightScrollBar.scrollFrame );
  47. RightScrollBar.scrollChild:SetHeight( RightScrollBar.scrollSize );
  48. RightScrollBar.scrollChild:SetWidth( RightScrollBar.scrollFrame:GetWidth() );
  49. RightScrollBar.scrollChild:SetAllPoints( RightScrollBar.scrollFrame );
  50. RightScrollBar.scrollFrame:SetScrollChild( RightScrollBar.scrollChild );
  51.  
  52.  
  53. for bnid = 1, #HelpHeaders do
  54.    
  55.     LeftScrollBar.scrollChild.button = CreateFrame('button', "HHeaderButton" .. bnid, LeftScrollBar.scrollChild)
  56.        
  57.     LeftScrollBar.scrollChild.button.text = LeftScrollBar.scrollChild.button:CreateFontString("HHeaderButtonText" .. bnid, 'DIALOG')
  58.     LeftScrollBar.scrollChild.button.text:SetFont([[Fonts\FRIZQT__.TTF]], 14)
  59.     LeftScrollBar.scrollChild.button.text:SetPoint("CENTER", LeftScrollBar.scrollChild.button, "CENTER", 0, 0)
  60.     LeftScrollBar.scrollChild.button.text:SetTextColor(.50, .90, .80, 1)
  61.    
  62. end
  63.  
  64. HHeaderButtonText1:SetText("General")
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 02-18-11 at 12:01 PM.
  Reply With Quote
02-18-11, 12:07 PM   #10
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
for bnid = 1, #HelpHeaders do

LeftScrollBar.scrollChild.button = CreateFrame('button', "HHeaderButton" .. bnid, LeftScrollBar.scrollChild)

LeftScrollBar.scrollChild.button.text = LeftScrollBar.scrollChild.button:CreateFontString("HHeaderButtonText" .. bnid, 'DIALOG')
LeftScrollBar.scrollChild.button.text:SetFont([[Fonts\FRIZQT__.TTF]], 14)
LeftScrollBar.scrollChild.button.text:SetPoint("CENTER", LeftScrollBar.scrollChild.button, "CENTER", 0, 0)
LeftScrollBar.scrollChild.button.text:SetTextColor(.50, .90, .80, 1)

end

My bigest question is... where it is setting "HHeaderButton" .. bnid which should make the name of the frame HHeaderButton1 right, so what do i use later to access it? LeftScrollBar.ScrollChild.button.HHeaderButton1? or just HHeaderButton1 or ugh...
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
02-18-11, 01:05 PM   #11
yssaril
A Warpwood Thunder Caller
 
yssaril's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 96
Code:
LeftScrollBar.scrollChild.button = CreateFrame('button', "HHeaderButton" .. bnid, LeftScrollBar.scrollChild)
the above code always sets the reference to your button to LeftScrollBar.scrollChild.button as such the reference is overwritten each time through the loop.

You should do something like this

Code:
LeftScrollBar.scrollChild.button[bnid] = CreateFrame('button', "HHeaderButton" .. bnid, LeftScrollBar.scrollChild)
that way you always have a reference to it via LeftScrollBar.scrollChild.button[i] (where i equals 1 through n)
  Reply With Quote
02-18-11, 01:28 PM   #12
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
so then this should set the first button's text to general right? its telling me on the settext line that button1 does not exist... i also tried being literal and putting button[1] but then it tells me "button" does not exist.

lua Code:
  1. for bnid = 1, #HelpHeaders do
  2.     LeftScrollBar.scrollChild.button[bnid] = CreateFrame('button', "HHeaderButton" .. bnid, LeftScrollBar.scrollChild)
  3.    
  4.        
  5.     LeftScrollBar.scrollChild.button[bnid].text = LeftScrollBar.scrollChild.button[bnid]:CreateFontString("HHeaderButtonText" .. bnid, 'DIALOG')
  6.     LeftScrollBar.scrollChild.button[bnid].text:SetFont([[Fonts\FRIZQT__.TTF]], 14)
  7.     LeftScrollBar.scrollChild.button[bnid].text:SetPoint("CENTER", LeftScrollBar.scrollChild.button[bnid], "CENTER", 0, 0)
  8.     LeftScrollBar.scrollChild.button[bnid].text:SetTextColor(.50, .90, .80, 1)
  9.    
  10. end
  11.  
  12. LeftScrollBar.scrollChild.button1.text:SetText("General")

i think the method of using LeftScrollBar.scrollChild.button[bnid] is not right for some reason.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 02-18-11 at 01:38 PM.
  Reply With Quote
02-18-11, 04:34 PM   #13
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Assuming you wanted to make a table of buttons then yes you are doing it right. However, just in case I would add the following line just above this one :

LeftScrollBar.scrollChild.button[bnid] = CreateFrame('button', "HHeaderButton" .. bnid, LeftScrollBar.scrollChild)

LeftScrollBar.scrollChild.button = LeftScrollBar.scrollChild.button or {}


Then assuming bnid is a value it will give the table an index linked list of buttons.

To access you would do something like:

LeftScrollBar.scrollChild.button[1] and not LeftScrollBar.scrollChild.button1 unless that is something in tables I haven't come across yet.
__________________
  Reply With Quote
02-18-11, 04:49 PM   #14
yssaril
A Warpwood Thunder Caller
 
yssaril's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 96
LeftScrollBar.scrollChild.button1 will not work (and as always you have to make sure that you create your tables before using them otherwise you will get errors )
  Reply With Quote
02-18-11, 08:11 PM   #15
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
The table does not actually have the buttons it only contains the name of the button and the big chunk of help text that corresponds with that button.

Ive run into this problem before... i think i need to be turning the bnid part into a string for the something.somethings then back to a table entry but pull the table entrys string name for the set text's and such...

local HelpHeaders = {
--button name = bulk help text

['General'] = 'blahblahgeneral',
['Buttons'] = 'blahblahbuttons',
['Frame Mover'] = 'blahblahmover',
['Chat'] = 'blahblahchat',
['Tooltips'] = 'blahblahtooltips',
['Unit Frames'] = 'blahblahunitframes',
['Backpack'] = 'blahblahbakpak',
['DashBoard'] = 'blahblahdashboard',
['HUD'] = 'blahblahhud',
['Development'] = 'blahblahdevtools',
}
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 02-18-11 at 08:15 PM.
  Reply With Quote
02-18-11, 08:42 PM   #16
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Even if you want to access the bnid as a string it is still technically a table element.


EG.

Code:
tblName = {}
tblName.VarString is the same as tblName["VarString"]
tblName.subTblName = {}
tblName.subTblName.AnotherString 
is the same as tblName.subTblName["AnotherString"] 
and the same as tblName["subTblName"].AnotherString 
and the same as tblName["subTblName]["AnotherString"]  
As I found out myself recently while playing with tables :D
These can also be initialised straight off the bat as :

Code:
tblName = {
  VarString = "...."
  subTblName = {
    AnotherString = "---"
  }
}
In both situations each table of data has to be initialised before it can be used.
__________________

Last edited by Xrystal : 02-18-11 at 08:45 PM.
  Reply With Quote
02-18-11, 09:47 PM   #17
yssaril
A Warpwood Thunder Caller
 
yssaril's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 96
i think it boils down to your understanding of how lua tables work and are constructed http://www.lua.org/pil/3.6.html would be a usefull read for you
  Reply With Quote
02-18-11, 10:48 PM   #18
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
okay so this is not supposed to point to the table but rather be a simple string added to button LeftScrollBar.scrollChild.button[bnid] so how would that be done? ."button".. bnid?

my understanding was that for bnid = 1, #HelpHeaders do just gets the number of entrys in the table so bnid should just be 1-number of table entrys. and should be a string only. then for the settext it should be HelpHeaders[1] and that would pull general from the table correct?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
02-19-11, 12:09 AM   #19
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Okay, using your example of :
Code:
local HelpHeaders = {
--button name = bulk help text
['General'] = 'blahblahgeneral',
['Buttons'] = 'blahblahbuttons',
['Frame Mover'] = 'blahblahmover',
['Chat'] = 'blahblahchat',
['Tooltips'] = 'blahblahtooltips',
['Unit Frames'] = 'blahblahunitframes',
['Backpack'] = 'blahblahbakpak',
['DashBoard'] = 'blahblahdashboard',
['HUD'] = 'blahblahhud',
['Development'] = 'blahblahdevtools',
}
To get this to create a button for each caption:
Code:
for name,caption in pairs(HelpHeaders) do
     LeftScrollBar.scrollChild.button = LeftScrollBar.scrollChild.button or {}
     LeftScrollBar.scrollChild.button[name] = CreateFrame('button', "HHeaderButton" .. name, LeftScrollBar.scrollChild)
     LeftScrollBar.scrollChild.button[name].text = LeftScrollBar.scrollChild.button[name]:CreateFontString("HHeaderButtonText" .. name, 'DIALOG')
    LeftScrollBar.scrollChild.button[name].text:SetFont([[Fonts\FRIZQT__.TTF]], 14)
LeftScrollBar.scrollChild.button[name].text:SetPoint("CENTER", LeftScrollBar.scrollChild.button[name], "CENTER", 0, 0)
   LeftScrollBar.scrollChild.button[name].text:SetTextColor(.50, .90, .80, 1)
   LeftScrollBar.scrollChild.button[name].text:SetText(caption)
end
This would cycle through your list and create a button for each item. So that the table would look like this:

LeftScrollBar.scrollChild.button["General"] with text as 'blahblahgeneral'
LeftScrollBar.scrollChild.button['Buttons'] with text as 'blahblahbuttons'
LeftScrollBar.scrollChild.button['Frame Mover'] with text as 'blahblahmover'
LeftScrollBar.scrollChild.button['Chat'] with text as 'blahblahchat'
LeftScrollBar.scrollChild.button['Tooltips'] with text as 'blahblahtooltips'
LeftScrollBar.scrollChild.button['Unit Frames'] with text as 'blahblahunitframes'
LeftScrollBar.scrollChild.button['Backpack'] with text as 'blahblahbakpak'
LeftScrollBar.scrollChild.button['DashBoard'] with text as 'blahblahdashboard'
LeftScrollBar.scrollChild.button['HUD'] with text as 'blahblahhud'
LeftScrollBar.scrollChild.button['Development'] with text as 'blahblahdevtools'

LeftScrollBar.scrollChild.button['Development'] of course can also be accessed by using LeftScrollBar.scrollChild.button.Development after it is created but during the creation routine it needs to be in the [] due to it being a variable and not a physical string.

Hopefully that will be enough for you to see what may need changing in your code to get it to do what you want. Just replace the value with the variable that holds the value you want displayed.
__________________

Last edited by Xrystal : 02-19-11 at 12:34 AM.
  Reply With Quote
02-19-11, 07:58 AM   #20
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
hmm so is it possible to change the table from variables to physical strings? Like within the table? i know on my frame mover system that vrul helped me with we made the options frame display the list of table entrys as though they were just string entrys.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Scrolling frames.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off