-
Notifications
You must be signed in to change notification settings - Fork 42
List
Lists are objects where you can create endless entrys and the user can choose one of them
Here is a example of how to create a standard list:
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aList = mainFrame:addList("myFirstList"):show()This will create a default list with the size 8 width and 5 height on position 1 1 (relative to its parent frame), the default background is colors.lightGray, the default text color is colors.black and the default zIndex is 5. The default horizontal text align is "center", default symbol is ">"
Here are all possible functions available for lists. Remember list inherit from object:
Adds a item to the list
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aList = mainFrame:addList("myFirstList"):show()
aList:addItem("1. Entry")
aList:addItem("2. Entry",colors.yellow)
aList:addItem("3. Entry",colors.yellow,colors.green)args: text, bgcolor, fgcolor, ..., text is the displayed text, bgcolor and fgcolors the colors of background/text and args (...) is something dynamic, you wont see them but if you require some more information per item you can use that.
returns: the object
Removes a item to the list
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aList = mainFrame:addList("myFirstList"):show()
aList:addItem("1. Entry")
aList:addItem("2. Entry",colors.yellow)
aList:addItem("3. Entry",colors.yellow,colors.green)
aList:removeItem(2)args: item table (you can get with :getValue()) OR item index
returns: the object
Sets the background of the item which is currently selected
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aList = mainFrame:addList("myFirstList"):show()
aList:addItem("1. Entry")
aList:addItem("2. Entry",colors.yellow)
aList:addItem("3. Entry",colors.yellow,colors.green)
aList:setActiveItemBackground(colors.green)args: any color
returns: the object
Sets the foreground of the item which is currently selected
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aList = mainFrame:addList("myFirstList"):show()
aList:addItem("1. Entry")
aList:addItem("2. Entry",colors.yellow)
aList:addItem("3. Entry",colors.yellow,colors.green)
aList:setActiveItemForeground(colors.red)args: any color
returns: the object
Sets item background colors in the list you can set as many colors as you want, it will set one color per line, if it got to the last color it will go back to the first color
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aList = mainFrame:addList("myFirstList"):show()
aList:addItem("1. Entry")
aList:addItem("2. Entry",colors.yellow)
aList:addItem("3. Entry",colors.yellow,colors.green)
aList:setItemColors(colors.red,colors.blue)args: any color - multiple colors possible
returns: the object
Sets item text colors in the list you can set as many colors as you want, it will set one color per line, if it got to the last color it will go back to the first color
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aList = mainFrame:addList("myFirstList"):show()
aList:addItem("1. Entry")
aList:addItem("2. Entry",colors.yellow)
aList:addItem("3. Entry",colors.yellow,colors.green)
aList:setItemTextColors(colors.blue,colors.red)args: any color - multiple colors possible
returns: the object
adds a scrollbar to be able to scroll trough the list without mouse_scroll
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aList = mainFrame:addList("myFirstList"):show()
local aScrollbar = mainFrame:addScrollbar("myFirstScrollbar"):show()
aList:addItem("1. Entry")
aList:addItem("2. Entry",colors.yellow)
aList:addItem("3. Entry",colors.yellow,colors.green)
aList:addScrollbar(aScrollbar)args: scrollbar object
returns: the object
sets the symbol of the selected item before text
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aList = mainFrame:addList("myFirstList"):show()
aList:addItem("1. Entry")
aList:addItem("2. Entry",colors.yellow)
aList:addItem("3. Entry",colors.yellow,colors.green)
aList:setSymbol(" ")args: you can choose any symbol, if you dont want a symbol just set it to ""
returns: the object
Get the selected item informations:
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aList = mainFrame:addList("myFirstList"):show()
aList:addItem("1. Entry")
aList:addItem("2. Entry",colors.yellow)
aList:addItem("3. Entry",colors.yellow,colors.green)
aList:onChange(function(self)
NyoUI.debug(self:getValue().text,self:getValue().bgcolor,self:getValue().fgcolor,self:getValue().vars)
end)Thanks for checking out our wiki, join our discord for more help: discord.gg/yM7kndJdJJ