- New Objects (Flexbox, Graph, Treeview) - Pluginsystem to add/remove functionality - Reworked the entire Object system, instead of one big Object Class we have multiple classes: Object, VisualObject, ChangeableObject - Instead of one big Frame Class we have multiple Frame Classes: BaseFrame, Frame, MovableFrame, ScrollableFrame, MonitorFrame, Flexbox - Removed the Animation Object, and added a animation plugin instead - Removed the Graphic Object and merged it's functionality with the image object - Updated currently existing objects
7.0 KiB
7.0 KiB
Lists are objects where you can create endless entries, and the user is able to select one of them
If you want to access values inside items this is how the table for single items is made (just a example):
item = {
text="1. Entry",
bgCol=colors.black,
fgCol=colors.white
args = {}
}
Remember Lists also inherits from Object
addItem
Adds a item into the list
Parameters:
stringThe entry namenumber|colorunique default background color - optionalnumber|colorunique default text color - optionalanyany value - you could access this later in a :onChange() event (you need to use :getValue()) - optional
Returns:
objectThe object in use
Usage:
- Creates a default list with 3 entries
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)
<list>
<item><text>1. Entry</text></item>
<item><text>2. Entry</text><bg>yellow</bg></item>
<item><text>3. Entry</text><bg>yellow</bg><fg>green</fg></item>
</list>
removeItem
Removes a item from the list
Parameters:
numberThe index which should get removed
Returns:
objectThe object in use
Usage:
- Creates a default list with 3 entries and removes the second one.
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:removeItem(2)
editItem
Edits a item from the list
Parameters:
numberThe index which should be editedstringThe new item namenumberthe new item background color - optionalnumberThe new item text color - optionalanyNew additional information - optional
Returns:
objectThe object in use
Usage:
- Creates a default list with 3 entries and changes the second one.
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:editItem(2, "Still 2. Entry", colors.red)
getItem
Returns a item by index
Parameters:
numberThe index which should be returned
Returns:
tableThe item table example: {text="1. Entry", bgCol=colors.black, fgCol=colors.white}
Usage:
- Creates a default list with 3 entries and edits the second one.
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:getItem(2).text)
getItemCount
Returns the current item count
Returns:
numberThe item list count
Usage:
- Creates a default list with 3 entries and prints the current item count.
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:getItemCount())
getAll
Returns all items as table
Returns:
tableAll items
Usage:
- Creates a default menubar with 3 entries and prints a table.
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:getAll())
selectItem
selects a item in the list (same as a player would click on a item)
Parameters:
numberThe index which should get selected
Returns:
objectThe object in use
Usage:
- Creates a default list with 3 entries and selects the second entry.
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:selectItem(2)
clear
Removes all items.
Returns:
objectThe object in use
Usage:
- Creates a default list with 3 entries and removes them immediatley. Which makes no sense.
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:clear()
getItemIndex
returns the item index of the currently selected item
Returns:
numberThe current index
Usage:
- Creates a default list with 3 entries selects the second entry and prints the currently selected index.
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:selectItem(2)
basalt.debug(aList:getItemIndex())
setSelectedItem
Sets the background and the foreground of the item which is currently selected
Parameters:
number|colorThe background color which should be usednumber|colorThe text color which should be used
Returns:
objectThe object in use
Usage:
- Creates a default list with 4 entries and sets the selection background color to green.
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)
<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>
setOffset
Sets the offset of the list (the same as you would scroll) - default is 0
Parameters:
numberThe offset value
Returns:
objectThe object in use
Usage:
- Creates a default list with 6 entries and sets the offset to 3.
local mainFrame = basalt.createFrame()
local aList = mainFrame:addList()
:addItem("1. Entry")
:addItem("2. Entry")
:addItem("3. Entry")
:addItem("4. Entry")
:addItem("5. Entry")
:addItem("6. Entry")
:setOffset(3)
<list offset="3">
<item><text>1. Entry</text></item>
<item><text>2. Entry</text></item>
<item><text>3. Entry</text></item>
<item><text>4. Entry</text></item>
<item><text>5. Entry</text></item>
<item><text>6. Entry</text></item>
</list>
getOffset
Returns the current index offset
Returns:
numberoffset value
Usage:
- Creates a default list with 6 entries and sets the offset to 3, also prints the current offset.
local mainFrame = basalt.createFrame()
local aList = mainFrame:addList()
:addItem("1. Entry")
:addItem("2. Entry")
:addItem("3. Entry")
:addItem("4. Entry")
:addItem("5. Entry")
:addItem("6. Entry")
:setOffset(3)
basalt.debug(aList:getOffset())