From 21422fa5f100c7bde0e66640163cab705166f8c4 Mon Sep 17 00:00:00 2001
From: Robert Jelic <36573031+NoryiE@users.noreply.github.com>
Date: Mon, 2 May 2022 20:54:14 +0200
Subject: [PATCH] Updated List (markdown)
---
List.md | 152 +++++++++++++++++++++++++-------------------------------
1 file changed, 68 insertions(+), 84 deletions(-)
diff --git a/List.md b/List.md
index bfbe5e7..2a55096 100644
--- a/List.md
+++ b/List.md
@@ -3,137 +3,121 @@ Lists are objects where you can create endless entrys and the user can choose on
Here is a example of how to create a standard list:
````lua
-local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
+local mainFrame = basalt.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](https://github.com/NoryiE/NyoUI/wiki/Object):
+Here are all possible functions available for lists. Remember list inherit from [object](https://github.com/NoryiE/basalt/wiki/Object):
## addItem
Adds a item to the list
````lua
-local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
+local mainFrame = basalt.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
+**parameters:** string text, number bgcolor, number fgcolor, any ... - (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:** self
## removeItem
-Removes a item to the list
+Removes a item from the list
````lua
-local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
+local mainFrame = basalt.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
+**parameters:** number index
+**returns:** self
-## setActiveItemBackground
+## editItem
+Edits a item on the list
+
+````lua
+local mainFrame = basalt.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:editItem(3,"3. Edited Entry",colors.yellow,colors.green)
+````
+**parameters:** number index, string text, number bgcolor, number fgcolor, any ...
+**returns:** self
+
+## setScrollable
+Makes the list scrollable
+
+````lua
+local mainFrame = basalt.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:setScrollable(true)
+````
+**parameters:** boolean isScrollable
+**returns:** self
+
+## selectItem
+selects a item in the list (same as a player would click on a item)
+
+````lua
+local mainFrame = basalt.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:selectItem(1)
+````
+**parameters:** number index
+**returns:** self
+
+## setSelectedItem
Sets the background of the item which is currently selected
````lua
-local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
+local mainFrame = basalt.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)
+aList:setSelectedItem(colors.green, colors.blue)
````
-**args:** any color
-**returns:** the object
+**parameters:** number bgcolor, number fgcolor, boolean isActive (isActive means if different colors for selected item should be used)
+**returns:** self
-## setActiveItemForeground
-Sets the foreground of the item which is currently selected
+## setOffset
+sets the list offset (will automatically change if scrolling is active)
````lua
-local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
+local mainFrame = basalt.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)
+aList:setOffset(3)
````
-**args:** any color
-**returns:** the object
+**parameters:** number offsetValue
+**returns:** self
-## setItemColors
-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
+## getOffset
+returns the current offset
````lua
-local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
+local mainFrame = basalt.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)
+aList:getOffset()
````
-**args:** any color - multiple colors possible
-**returns:** the object
-
-## setItemTextColors
-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
-
-````lua
-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
-
-## addScrollbar
-adds a scrollbar to be able to scroll trough the list without mouse_scroll
-
-````lua
-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
-
-## setSymbol
-sets the symbol of the selected item before text
-
-````lua
-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
-
-# Examples
-Get the selected item informations:
-````lua
-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)
-````
\ No newline at end of file
+**parameters:** -
+**returns:** number offsetValue
\ No newline at end of file