Updated Radio (markdown)

Robert Jelic
2022-05-02 21:06:30 +02:00
parent 5a74473ffd
commit 5b88153fcb

122
Radio.md

@@ -1,48 +1,122 @@
Radios are objects, where the user can choose between different items.<br>
Radios are objects where you can create endless entrys the user can click on a button and it opens a "list" where the user can choose a entry
Here is a example of how to create a standard radio:
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aRadio = mainFrame:addRadio("myFirstRadio"):show()
````
This will create a default radio on position 1 1 (relative to its parent frame), the default background is colors.lightBlue, the default text color is colors.black and the default zIndex is 5.
Here are all possible functions available for radios. Remember radio inherit from [object](https://github.com/NoryiE/NyoUI/wiki/Object):
Here are all possible functions available for radios: <br>
Remember radio inherits from [object](https://github.com/NoryiE/basalt/wiki/Object):
## addItem
Adds a item to the radio
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aRadio = mainFrame:addRadio("myFirstRadio"):show()
aRadio:addItem("1. Entry")
aRadio:addItem("2. Entry",5,1,colors.yellow)
aRadio:addItem("3. Entry",5,4,colors.yellow,colors.green)
aRadio:addItem("1. Entry",3,4)
aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
````
**args:** text, x, y bgcolor, fgcolor, ..., text is the displayed text, x and y are the position, where you want the item to be created, 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.<br>
**returns:** the object<br>
**parameters:** string text, number x, number y, 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)<br>
**returns:** self<br>
## removeItem
Removes a item to the radio
Removes a item from the radio
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aRadio = mainFrame:addRadio("myFirstRadio"):show()
aRadio:addItem("1. Entry")
aRadio:addItem("2. Entry",colors.yellow)
aRadio:addItem("3. Entry",colors.yellow,colors.green)
aRadio:addItem("1. Entry",3,4)
aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
aRadio:removeItem(2)
````
**args:** item table (you can get with :getValue()) OR item index<br>
**returns:** the object<br>
**parameters:** number index<br>
**returns:** self<br>
## editItem
Edits a item on the radio
## setSymbol
changes the selected symbol
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aInput = mainFrame:addInput("myFirstInput"):setInputType("password"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aRadio = mainFrame:addRadio("myFirstRadio"):show()
aRadio:addItem("1. Entry",3,4)
aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
aRadio:editItem(3,"3. Edited Entry",3,6,colors.yellow,colors.green)
````
**args:** char<br>
**returns:** the object<br>
**parameters:** number index, string text, number x, number y, number bgcolor, number fgcolor, any ...<br>
**returns:** self<br>
## setScrollable
Makes the radio scrollable
````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aRadio = mainFrame:addRadio("myFirstRadio"):show()
aRadio:addItem("1. Entry",3,4)
aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
aRadio:setScrollable(true)
````
**parameters:** boolean isScrollable<br>
**returns:** self<br>
## selectItem
selects a item in the radio (same as a player would click on a item)
````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aRadio = mainFrame:addRadio("myFirstRadio"):show()
aRadio:addItem("1. Entry",3,4)
aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
aRadio:selectItem(1)
````
**parameters:** number index<br>
**returns:** self<br>
## clear
clears the entire list (radio)
````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aRadio = mainFrame:addRadio("myFirstRadio"):show()
aRadio:addItem("1. Entry",3,4)
aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
aRadio:clear()
````
**parameters:** -<br>
**returns:** self<br>
## getItemIndex
returns the item index of the currently selected item
````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aRadio = mainFrame:addRadio("myFirstRadio"):show()
aRadio:addItem("1. Entry",3,4)
aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
aRadio:getItemIndex()
````
**parameters:** -<br>
**returns:** number index<br>
## setSelectedItem
Sets the background of the item which is currently selected
````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aRadio = mainFrame:addRadio("myFirstRadio"):show()
aRadio:addItem("1. Entry",3,4)
aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
aRadio:setSelectedItem(colors.green, colors.blue)
````
**parameters:** number bgcolor, number fgcolor, boolean isActive (isActive means if different colors for selected item should be used)<br>
**returns:** self<br>