Docs
- added a onSelect event for lists - added docs for onSelect - added addPlugin and addObject docs
This commit is contained in:
@@ -33,6 +33,8 @@ You are now able to access the following list of methods:
|
||||
|[setVariable](objects/Basalt/setVariable.md)|Sets a variable which you can access via XML
|
||||
|[stopUpdate / stop](objects/Basalt/stopUpdate.md)|Stops the currently active event and draw listener
|
||||
|[update](objects/Basalt/update.md)|Starts the event and draw listener once
|
||||
|[addObject](objects/Basalt/addObject.md)|Adds new object files/folders
|
||||
|[addPlugin](objects/Basalt/addPlugin.md)|Adds new plugin files/folders
|
||||
|
||||
## Examples
|
||||
|
||||
|
||||
24
docs/objects/Basalt/addObject.md
Normal file
24
docs/objects/Basalt/addObject.md
Normal file
@@ -0,0 +1,24 @@
|
||||
## addObject
|
||||
|
||||
### Description
|
||||
|
||||
The `basalt.addObject` method allows you to add new custom objects (elements) to the Basalt framework. This enables extending the framework with additional functionality tailored to specific needs. It's important to note that this method must be called before `basalt.autoUpdate` and can only be used during the initialization phase, not during runtime.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` The path to the Lua file or folder containing the custom object(s).
|
||||
|
||||
### Usage
|
||||
|
||||
* Loads a custom objects folder:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
-- Add the custom object(s):
|
||||
basalt.addObject("objects")
|
||||
|
||||
-- Rest of the code
|
||||
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
24
docs/objects/Basalt/addPlugin.md
Normal file
24
docs/objects/Basalt/addPlugin.md
Normal file
@@ -0,0 +1,24 @@
|
||||
## addPlugin
|
||||
|
||||
### Description
|
||||
|
||||
The `basalt.addPlugin` method allows you to add new custom plugins to the Basalt framework. This enables extending the framework with additional functionality tailored to specific needs. It's important to note that this method must be called before `basalt.autoUpdate` and can only be used during the initialization phase, not during runtime.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` The path to the Lua file or folder containing the plugin(s).
|
||||
|
||||
### Usage
|
||||
|
||||
* Loads a custom plugins folder:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
-- Add the custom plugin(s):
|
||||
basalt.addPlugin("plugin")
|
||||
|
||||
-- Rest of the code
|
||||
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
@@ -21,6 +21,12 @@ In addition to the Object and VisualObject methods, lists also have the followin
|
||||
|[getSelectionColor](objects/List/getSelectionColor.md)|Returns default bg and fg selection color
|
||||
|[isSelectionColorActive](objects/List/isSelectionColorActive.md)|Returns if it is using selection color
|
||||
|
||||
## Events
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|[onSelect](objects/List/onSelect.md)|Fires when a item on the list get's selected
|
||||
|
||||
A item-table in lists looks like the following example:
|
||||
|
||||
```lua
|
||||
@@ -43,7 +49,7 @@ aList:addItem("Item 1")
|
||||
aList:addItem("Item 2", colors.yellow)
|
||||
aList:addItem("Item 3", colors.yellow, colors.green)
|
||||
|
||||
aList:onChange(function(self, item)
|
||||
aList:onSelect(function(self, item)
|
||||
basalt.debug("Selected item: ", item.text)
|
||||
end)
|
||||
```
|
||||
|
||||
33
docs/objects/List/onSelect.md
Normal file
33
docs/objects/List/onSelect.md
Normal file
@@ -0,0 +1,33 @@
|
||||
## onSelect
|
||||
|
||||
### Description
|
||||
|
||||
`onSelect(self, event, item)`
|
||||
|
||||
The onSelect event is triggered when a item on the list gets selected.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Add an onSelect event to a list:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local main = basalt.createFrame()
|
||||
local list = main:addList()
|
||||
|
||||
list:addItem("Entry 1")
|
||||
list:addItem("Entry 2")
|
||||
|
||||
function listOnSelect(self, event, item)
|
||||
basalt.debug("Item got selected:", item.text)
|
||||
end
|
||||
|
||||
list:onSelect(listOnSelect)
|
||||
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
Reference in New Issue
Block a user