- Docs Update
- Updated List & ScrollbarFrame Docs - Added setOptions for the List Object
This commit is contained in:
@@ -59,6 +59,20 @@ return function(name, basalt)
|
||||
return self
|
||||
end,
|
||||
|
||||
setOptions = function(self, ...)
|
||||
list = {}
|
||||
for k,v in pairs(...)do
|
||||
if(type(v)=="string")then
|
||||
table.insert(list, { text = v, bgCol = self:getBackground(), fgCol = self:getForeground(), args = {} })
|
||||
else
|
||||
table.insert(list, { text = v[1], bgCol = v[2] or self:getBackground(), fgCol = v[3] or self:getForeground(), args = v[4] or {} })
|
||||
end
|
||||
end
|
||||
self:setValue(list[1], false)
|
||||
self:updateDraw()
|
||||
return self
|
||||
end,
|
||||
|
||||
setOffset = function(self, yOff)
|
||||
yOffset = yOff
|
||||
self:updateDraw()
|
||||
@@ -83,6 +97,10 @@ return function(name, basalt)
|
||||
return list
|
||||
end,
|
||||
|
||||
getOptions = function(self)
|
||||
return list
|
||||
end,
|
||||
|
||||
getItemIndex = function(self)
|
||||
local selected = self:getValue()
|
||||
for key, value in pairs(list) do
|
||||
|
||||
@@ -9,7 +9,8 @@ In addition to the Object and VisualObject methods, lists also have the followin
|
||||
|[editItem](objects/List/editItem.md)|Changes an already existing item in the list
|
||||
|[getItem](objects/List/getItem.md)|Returns an item by its index
|
||||
|[getItemCount](objects/List/getItemCount.md)|Returns the item count
|
||||
|[getAll](objects/List/getAll.md)|Returns the entire list as a table
|
||||
|[setOptions](objects/List/setOptions.md)|Updates the list options
|
||||
|[getOptions](objects/List/getOptions.md)|Returns the entire list as a table
|
||||
|[selectItem](objects/List/selectItem.md)|Selects an item
|
||||
|[clear](objects/List/clear.md)|Makes the entire list empty
|
||||
|[getItemIndex](objects/List/getItemIndex.md)|Returns the currently active item index
|
||||
|
||||
22
docs/objects/List/getOptions.md
Normal file
22
docs/objects/List/getOptions.md
Normal file
@@ -0,0 +1,22 @@
|
||||
## getOptions
|
||||
|
||||
### Description
|
||||
|
||||
Returns all items as a table.
|
||||
|
||||
#### Returns
|
||||
|
||||
1. `table` All items
|
||||
|
||||
### Usage
|
||||
|
||||
* Creates a default list with 3 entries and prints a table.
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aList = mainFrame:addList()
|
||||
aList:addItem("1. Entry")
|
||||
aList:addItem("2. Entry", colors.yellow)
|
||||
aList:addItem("3. Entry", colors.yellow, colors.green)
|
||||
basalt.debug(aList:getOptions())
|
||||
```
|
||||
35
docs/objects/List/setOptions.md
Normal file
35
docs/objects/List/setOptions.md
Normal file
@@ -0,0 +1,35 @@
|
||||
## setOptions
|
||||
|
||||
### Description
|
||||
|
||||
The `setOptions` method allows you to change the options of a List object. This method accepts a table containing the new options you want to set for the List object.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `table` A table containing the new options to set for the List object.
|
||||
|
||||
#### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Creates a default list with 3 entries, then changes the background color and selection color of the list.
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aList = mainFrame:addList()
|
||||
aList:setOptions("Entry 1", "Entry 2", "Entry 3")
|
||||
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aList = mainFrame:addList()
|
||||
aList:setOptions("Entry 1", {"Entry 2", colors.yellow}, {"Entry 3", colors.yellow, colors.green})
|
||||
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
@@ -1,28 +0,0 @@
|
||||
## setSelectedItem
|
||||
Sets the background and the foreground of the item which is currently selected
|
||||
|
||||
#### Parameters:
|
||||
1. `number|color` The background color which should be used
|
||||
2. `number|color` The text color which should be used
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default list with 4 entries and sets the selection background color to green.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aList = mainFrame:addList()
|
||||
aList:addItem("1. Entry")
|
||||
aList:addItem("2. Entry",colors.yellow)
|
||||
aList:addItem("3. Entry",colors.yellow,colors.green)
|
||||
aList:addItem("4. Entry")
|
||||
aList:setSelectedItem(colors.green, colors.red)
|
||||
```
|
||||
```xml
|
||||
<list selectionBG="green" selectionFG="red">
|
||||
<item><text>1. Entry</text></item>
|
||||
<item><text>2. Entry</text><bg>yellow</bg></item>
|
||||
<item><text>2. Entry</text><bg>yellow</bg><fg>green</fg></item>
|
||||
</list>
|
||||
```
|
||||
@@ -24,7 +24,7 @@ aList:addItem("1. Entry")
|
||||
aList:addItem("2. Entry",colors.yellow)
|
||||
aList:addItem("3. Entry",colors.yellow,colors.green)
|
||||
aList:addItem("4. Entry")
|
||||
aList:setSelectedItem(colors.green, colors.red)
|
||||
aList:setSelectionColor(colors.green, colors.red)
|
||||
```
|
||||
|
||||
```xml
|
||||
|
||||
26
docs/objects/ScrollableFrame/setScrollAmount.md
Normal file
26
docs/objects/ScrollableFrame/setScrollAmount.md
Normal file
@@ -0,0 +1,26 @@
|
||||
## setScrollAmount
|
||||
|
||||
### Description
|
||||
|
||||
The setScrollAmount method allows you to set the maximum allowed scroll value. This value determines how far the content of the ScrollableFrame can be scrolled.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` The maximum scroll value
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Set the scrolling direction for a ScrollableFrame
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local scrollableFrame = mainFrame:addScrollableFrame()
|
||||
|
||||
scrollableFrame:setScrollAmount(10)
|
||||
```
|
||||
|
||||
By setting the scroll amount, you can control how much the content of the ScrollableFrame can be scrolled, ensuring that the user can only view a specific range of content at a time.
|
||||
Reference in New Issue
Block a user