Download
(2 Kb)
Download
Updated: 02/17/21 02:26 AM
Compatibility:
Flames of Ambition (6.3.5)
Markarth (6.2.5)
Updated:02/17/21 02:26 AM
Created:07/19/15 06:24 PM
Monthly downloads:1,859
Total downloads:123,834
Favorites:17
MD5:
LibScroll  Popular! (More than 5000 hits)
Version: 2
by: circonian, Baertram
What does it do?
It handles the basic code for creating a scrollList & updating the scrollList data for you.

Why did I write it?
I have no idea I found it laying around in a folder...I think I worked on to many addons with scrollLists & got sick of copy/pasting/editing code & figured a simple lib to just drop in the addons would be easier. But, over time I've seen many questions about scrollLists & although this lib does not do a lot of work for you, I thought it might be useful to those who don't know the necessary code to create a scrollList. The lib can drastically cut down on what you need to know to create a working scrollList...and if you need to you can copy the setupCallback, OnRowSelect, SortScrollList, & SetupDataRow functions from my examples below & then you really don't need to know anything.

How do I create a scrollList with it?
I will give two complete addon examples at the end of this post, first lets look at the individual pieces of code you need.

Load the Library
At the top of your code file load the library:
Lua Code:
  1. local libScroll = LibScroll
Create the ScrollList
You will need to create a table containing the necessary information for initializing your scrollList. Below is an example containing all possible information you may include. Only the name, parent, & setupCallback are necessary, the rest are optional.

ScrollData table example:
Warning: Spoiler


Explanation of table items:
Warning: Spoiler


Then just call:
Lua Code:
  1. local scrollList = libScroll:CreateScrollList(scrollData)
Update the scrollList with your data
Create your table of dataItems to be loaded into the scrollList. Then just call Update and pass in your table:
Lua Code:
  1. scrollList:Update(dataItems)

dataItems table example:
The table for each individual data item can contain any data you want, this is only an example.
categoryId is optional, it is used to group items together in categories so you can show/hide groups of items by showing/hiding their categoryId.
Warning: Spoiler

That is all there is to it.

Available Functions:
scrollList:Clear() -- Clears all data from the scrollList
scrollList:Update (table dataItems) -- Pass in a table containing all of your data items for the scrollList to update the list with new data.

** Do note for the show/hide category functions to work the category values must be assigned to the scrollList by including them in the scrollData table that you pass to libScroll:CreateScrollList(scrollData) **
** Also these will only effect data items that have a categoryId assigned to them. As an example if you did not assign a categoryId to a data item & call HideAllCategories it will not be hidden **

scrollList:ShowAllCategories() -- Shows all data items that have a categoryId that matches one of the categories assigned to the scrollList. Data items that do not have a categoryId that matches one of the scrollList categories will not be effected.
scrollList:ShowOnlyCategory(integer categoryId) -- Shows only data items that have the given categoryId, all other data items are hidden (if they have a categoryId, items without a categoryId will not be effected).
scrollList:ShowCategory(integer categoryId) -- Shows data items that have the given categoryId.
scrollList:HideAllCategories() -- Hides all data items that have a categoryId that matches one of the categories assigned to the scrollList. Data items that do not have a categoryId that matches one of the scrollList categories will not be effected.
scrollList:HideCategory(integer categoryId) -- Hides data items that have the given categoryId.


A Complete (simple) example for creating a scrollList (no highlights, no select callbacks, & no sorting):
Warning: Spoiler


A Complete example with selection callbacks, row highlights, & a sorting function:
Warning: Spoiler
Version 2 (2021-02-17)
-Added own manifest txt with ## IsLibrary: true and ## AddOnVersion: 2
-Removed LibStub
-Added global variable LibScroll
Archived Files (1)
File Name
Version
Size
Uploader
Date
1
2kB
circonian
07/19/15 06:29 PM


Post A Reply Comment Options
Unread 02/17/21, 04:31 AM  
Baertram
Super Moderator
 
Baertram's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 4912
File comments: 5988
Uploads: 78
Re: Thank you!

Yw, I'm not using it, as you can see how it works from the ZOs code (well, you need to test and see in detail what is called when but adding some debug messages helped to understand it for me ). All examples and work done here credit to Circonian!
But an older addon still used it so I thought having a non LibStub + txt version would be good.

Originally Posted by Calamath
Thank you for updating.
I just needed to understand how UI controls work, so these samples are very helpful. 
Last edited by Baertram : 02/17/21 at 04:44 AM.
Report comment to moderator  
Reply With Quote
Unread 02/17/21, 04:10 AM  
Calamath
AddOn Author - Click to view AddOns

Forum posts: 36
File comments: 220
Uploads: 7
Thank you!

Thank you for updating.
I just needed to understand how UI controls work, so these samples are very helpful. 
Report comment to moderator  
Reply With Quote
Unread 07/20/15, 08:02 AM  
kerb9729
AddOn Author - Click to view AddOns

Forum posts: 56
File comments: 118
Uploads: 2
Sweet

LOL I guess you got tired of answering my questions about scrolllists =P

This will help someone greatly I am sure!
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: