Merge pull request #16 from Pyroxenium/docsify-feature

started docsify with custom theme
This commit is contained in:
Samuel Pizette
2022-05-30 02:24:11 -04:00
committed by GitHub
31 changed files with 1924 additions and 1665 deletions

View File

@@ -1,21 +1,27 @@
# Welcome to The Basalt Wiki! # Welcome to The Basalt Wiki!<br>
*Note: The Basalt Wiki is a work in progress, now also just migrated away from github wiki. Please treat Wiki errors the same as bugs and report them accordingly.*
_Note: The Basalt Wiki is a work in progress. Please treat Wiki errors the same as bugs and report them accordingly._
Here you can find information about how to use Basalt as well as examples of functional Basalt code. The aim of Basalt is to improve user interaction through visual display.
Here you can find information about how to use Basalt as well as examples of functional Basalt code. The aim of Basalt is to improve user interaction through visual display.
On the left side of this page you can find a Wiki Navigation, where you can find a more detailed list of Basalt's features
On the right side of this page you can find a Wiki Navigation, where you can find a more detailed list of Basalt's features
## About Basalt <br><br>
Basalt is intended to be an easy-to-understand UI Framework designed for CC:Tweaked (AKA Computer Craft: Tweaked) - a popular minecraft mod. For more information about CC:Tweaked, checkout the project's <a href="https://tweaked.cc/">home page</a>. ## About Basalt
## Quick Demo Basalt is intended to be an easy-to-understand UI Framework designed for CC:Tweaked (AKA Computer Craft: Tweaked) - a popular minecraft mod. For more information about CC:Tweaked, checkout the project's <a href="https://tweaked.cc/">home page</a>.
![Preview](https://media0.giphy.com/media/fvmNPshXKeU7FFA9iA/giphy.gif) <br><br>
## Questions & Bugs ## Quick Demo
![Preview](https://media0.giphy.com/media/fvmNPshXKeU7FFA9iA/giphy.gif)
Obviously NyoriE has implemented some easter eggs, _some people_ call them "bugs". If you happen to discover one of these just make a new <a href="https://github.com/Pyroxenium/Basalt/issues">issue</a>. <br><br>
Additionally, if you have questions about Basalt or how to make use of it, feel free to create a new discussion on <a href="https://github.com/Pyroxenium/Basalt/discussions">Basalt's Discussion Board</a>. ## Questions & Bugs
You may also join the Discord: https://discord.gg/yNNnmBVBpE Obviously I've implemented some easter eggs, _some people_ call them "bugs". If you happen to discover one of these just make a new <a href="https://github.com/NoryiE/Basalt/issues">issue</a>.
Additionally, if you have questions about Basalt or how to make use of it, feel free to create a new discussion on <a href="https://github.com/NoryiE/Basalt/discussions">Basalt's Discussion Board</a>.
You may also message me on Discord: NyoriE#8206
<br><br>

1
docs/_Footer.md Normal file
View File

@@ -0,0 +1 @@
Thanks for checking out our wiki, join our discord for more help: [discord.gg/yM7kndJdJJ](discord.gg/yM7kndJdJJ)

29
docs/_Sidebar.md Normal file
View File

@@ -0,0 +1,29 @@
- Getting Started
- [Home](Home.md)
- [Quick Start](Quick-Start.md)
- [Installer](Installer.md)
- Objects
- [Animation](Animation.md)
- [Basalt](Basalt.md)
- [Button](Button.md)
- [Checkbox](Checkbox.md)
- [Design](Design.md)
- [Dropdown](Dropdown.md)
- [Frame](Frame.md)
- [Input](Input.md)
- [Installer](Installer.md)
- [Label](Label.md)
- [List](List.md)
- [Menubar](Menubar.md)
- [Object](Object.md)
- [Pane](Pane.md)
- [Program](Program.md)
- [Radio](Radio.md)
- [Scrollbar](Scrollbar.md)
- [Slider](Slider.md)
- [Text Field](Textfield.md)
- [Thread](Thread.md)
- [Timer](Timer.md)
- Tips & Tricks
- [Component Logic](Executing-own-logic.md)
- [Changing Button Color](Change-colors-on-buttons-while-user-is-holding-it.md)

BIN
docs/_media/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

4
docs/_navbar.md Normal file
View File

@@ -0,0 +1,4 @@
- Getting Started
- [Home](Home.md)
- [Quick Start](docs/home/Quick-Start.md)
- [Installer](docs/objects/Installer.md)

View File

@@ -1,29 +1,29 @@
- Home - Home
- [Home](/) - [Home](Home.md)
- [Getting Started](/home/gettingStarted) - [Getting Started](home/gettingStarted)
- [Installer](/home/installer) - [Installer](home/installer)
- Objects - Objects
- [Animation](/objects/Animation) - [Animation](objects/Animation.md)
- [Basalt](/objects/Basalt) - [Basalt](objects/Basalt)
- [Button](/objects/Button) - [Button](objects/Button)
- [Checkbox](/objects/Checkbox) - [Checkbox](objects/Checkbox)
- [Dropdown](/objects/Dropdown) - [Dropdown](objects/Dropdown)
- [Frame](/objects/Frame) - [Frame](objects/Frame)
- [Image](/objects/Image) - [Image](objects/Image)
- [Input](/objects/Input) - [Input](objects/Input)
- [Label](/objects/Label) - [Label](objects/Label)
- [List](/objects/List) - [List](objects/List)
- [Menubar](/objects/Menubar) - [Menubar](objects/Menubar)
- [Object](/objects/Object) - [Object](objects/Object)
- [Pane](/objects/Pane) - [Pane](objects/Pane)
- [Program](/objects/Program) - [Program](objects/Program)
- [Radio](/objects/Radio) - [Radio](objects/Radio)
- [Scrollbar](/objects/Scrollbar) - [Scrollbar](objects/Scrollbar)
- [Silder](/obects/Slider) - [Slider](objects/Slider)
- [Textfield](/objects/Textfield) - [Text Field](objects/Textfield)
- [Thread](/objects/Thread) - [Thread](objects/Thread)
- [Timer](/objects/Timer) - [Timer](objects/Timer)
- Tips & tricks - Tips & Tricks
- [Executing own logic](/tips/logic) - [Executing own logic](tips/logic)
- [Changing button colors](/tips/buttons) - [Changing button colors](tips/buttons)

70
docs/home/Quick-Start.md Normal file
View File

@@ -0,0 +1,70 @@
Basalt aims to be a relatively small, easy to use framework.
Accordingly, we have provided an installation script.
Just use the following command in any CC:Tweaked shell:
`pastebin run ESs1mg7P`
This will download `basalt.lua` to your local directory
To load the framework, make use of the following snippet
````lua
--> For those who are unfamiliar with lua, dofile executes the code in the referenced file
local basalt = dofile("basalt.lua")
````
Here is a fully functioning example of Basalt code
````lua
local basalt = dofile("basalt.lua") --> Load the Basalt framework
--> Create the first frame. Please note that Basalt needs at least one active "non-parent" frame to properly supply events
--> When Basalt#createFrame makes use of unique identifiers (commonly referred to as UIDs), meaning that the supplied value must be UNIQUE
--> If the supplied UID is ambiguous, Basalt#createFrame returns a nil value
local mainFrame = basalt.createFrame("mainFrame")
--> Show the frame to the user
mainFrame:show()
local button = mainFrame:addButton("clickableButton") --> Add a button to the mainFrame (With a unique identifier)
--> Set the position of the button, Button#setPosition follows an x, y pattern.
--> The x value is how far right the object should be from its anchor (negative values from an anchor will travel left)
--> The y value is how far down the object should be from its anchor (negative values from an anchor will travel up)
button:setPosition(4, 4)
button:setText("Click me!") --> Set the text of our button
local function buttonClick() --> This function serves as our click logic
basalt.debug("I got clicked!")
end
--> Remember! You cannot supply buttonClick(), that will only supply the result of the function
--> Make sure the button knows which function to call when it's clicked
button:onClick(buttonClick)
button:show() --> Make the button visible, so the user can click it
basalt.autoUpdate() --> Basalt#autoUpdate starts the event listener to detect user input
````
If you're like us and strive for succinct and beautiful code, here is a cleaner implementation of the code above:
````lua
local basalt = dofile("basalt.lua")
local mainFrame = basalt.createFrame("mainFrame"):show()
local button = mainFrame --> Basalt returns an instance of the object on most methods, to make use of "call-chaining"
:addButton("clickableButton") --> This is an example of call chaining
:setPosition(4,4)
:setText("Click me!")
:onClick(
function()
basalt.debug("I got clicked!")
end)
:show()
basalt.autoUpdate()
````

View File

@@ -1,24 +1,49 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1"> <title>Document</title>
<meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple-dark.css"> <meta name="description" content="Description">
<title>Basalt Docs</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
</head> <!-- <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">-->
<body> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple-dark.css">
<div id="app"></div> <style>
<script> :root {
window.$docsify = { /* secondary: */
name: 'Basalt Docs', --theme-color: #16CC27;
repo: 'https://github.com/Pyroxenium/Basalt', --mono-hue: 120;
loadSidebar: true, --mono-saturation: 1%;
auto2top: true, --mono-shade3 : hsl(var(--mono-hue), var(--mono-saturation), 5%); /* #333333 */
// logo: 'path to logo' --mono-shade2 : hsl(var(--mono-hue), var(--mono-saturation), 6%); /* #4d4d4d */
}; --mono-shade1 : hsl(var(--mono-hue), var(--mono-saturation), 7%);
</script> --mono-base : hsl(var(--mono-hue), var(--mono-saturation), 20%); /* #808080 */
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script> --mono-tint1 : hsl(var(--mono-hue), var(--mono-saturation), 25%); /* #b3b3b3 */
<script src="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/js/docsify-themeable.min.js"></script> --mono-tint2 : hsl(var(--mono-hue), var(--mono-saturation), 30%); /* #e3e3e3 */
</body> --mono-tint3 : hsl(var(--mono-hue), var(--mono-saturation), 35%);
</html> --base-background-color: hsl(var(--mono-hue), var(--mono-saturation), 10%);
--sidebar-nav-pagelink-background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='11.2' viewBox='0 0 7 11.2'%3E%3Cpath d='M1.5 1.5l4 4.1 -4 4.1' stroke-width='1.5' stroke='%23575d5e' fill='none' stroke-linecap='square' stroke-linejoin='miter' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
--sidebar-nav-pagelink-background-image--active: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11.2' height='7' viewBox='0 0 11.2 7'%3E%3Cpath d='M1.5 1.5l4.1 4 4.1-4' stroke-width='1.5' stroke='%23575d5e' fill='none' stroke-linecap='square' stroke-linejoin='miter' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
--sidebar-nav-pagelink-background-image--collapse: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='11.2' viewBox='0 0 7 11.2'%3E%3Cpath d='M1.5 1.5l4 4.1 -4 4.1' stroke-width='1.5' stroke='%23575d5e' fill='none' stroke-linecap='square' stroke-linejoin='miter' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
--sidebar-nav-pagelink-background-image--loaded: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11.2' height='7' viewBox='0 0 11.2 7'%3E%3Cpath d='M1.5 1.5l4.1 4 4.1-4' stroke-width='1.5' stroke='%23575d5e' fill='none' stroke-linecap='square' stroke-linejoin='miter' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
</style>
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
logo: '/_media/logo.png',
loadNavbar: true,
loadSidebar: true,
subMaxLevel: 2,
homepage: 'Home.md',
name: 'Basalt',
repo: 'https://github.com/Pyroxenium/Basalt',
auto2top: true
}
</script>
<!-- Docsify v4 -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/js/docsify-themeable.min.js"></script>
</body>
</html>

View File

@@ -1,55 +1,53 @@
# Animation With animations you can create a beautiful experience for users while interacting with objects.<br>
For now the animation class is very basic, i will expand it in the future, but i have to say already now you can do almost everything you can imagine!
With animations you can create a beautiful experience for users while interacting with objects.<br>
For now the animation class is very basic, i will expand it in the future, but i have to say already now you can do almost everything you can imagine! Right now animation is a class which makes use of the timer event<br>
Here are all possible functions available for animations:
Right now animation is a class which makes use of the timer event<br>
Here are all possible functions available for animations: ## add
adds a new function to your animation
## add ````lua
adds a new function to your animation local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local testButton = mainFrame:addButton("myTestButton"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setPosition(3,3) end):wait(1):add(function() testButton:setPosition(1,1,"r") end):wait(2):add(function() testButton:setPosition(1,1,"r") end)
local testButton = mainFrame:addButton("myTestButton"):show()
local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setPosition(3,3) end):wait(1):add(function() testButton:setPosition(1,1,"r") end):wait(2):add(function() testButton:setPosition(1,1,"r") end) aAnimation:play() -- this will set the button position to 3,3, waits 1 sec., sets it to 4,4, waits 2 sec. and then sets the position to 5,5
````
aAnimation:play() -- this will set the button position to 3,3, waits 1 sec., sets it to 4,4, waits 2 sec. and then sets the position to 5,5 **parameters:** function<br>
```` **returns:** self<br>
**parameters:** function<br>
**returns:** self<br> ## wait
sets a wait timer for the next function after the previous function got executed, no wait timer calls the next function immediatly
## wait ````lua
sets a wait timer for the next function after the previous function got executed, no wait timer calls the next function immediatly local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local testButton = mainFrame:addButton("myTestButton"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setPosition(3,3) end):wait(1):add(function() testButton:setPosition(1,1,"r") end):wait(2):add(function() testButton:setPosition(1,1,"r") end)
local testButton = mainFrame:addButton("myTestButton"):show()
local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setPosition(3,3) end):wait(1):add(function() testButton:setPosition(1,1,"r") end):wait(2):add(function() testButton:setPosition(1,1,"r") end) aAnimation:play() -- this will set the button position to 3,3, waits 1 sec., sets it to 4,4, waits 2 sec. and then sets the position to 5,5
````
aAnimation:play() -- this will set the button position to 3,3, waits 1 sec., sets it to 4,4, waits 2 sec. and then sets the position to 5,5 **parameters:** timer - how long we should wait to call the next function<br>
```` **returns:** self<br>
**parameters:** timer - how long we should wait to call the next function<br>
**returns:** self<br> ## play
starts to play the animation
## play ````lua
starts to play the animation local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local testButton = mainFrame:addButton("myTestButton"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setBackground(colors.black) end):wait(1):add(function() testButton:setBackground(colors.gray) end):wait(1):add(function() testButton:setBackground(colors.lightGray) end)
local testButton = mainFrame:addButton("myTestButton"):show()
local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setBackground(colors.black) end):wait(1):add(function() testButton:setBackground(colors.gray) end):wait(1):add(function() testButton:setBackground(colors.lightGray) end) aAnimation:play() -- changes the background color of that button from black to gray and then to lightGray
````
aAnimation:play() -- changes the background color of that button from black to gray and then to lightGray **parameters:** [endlessloop] - bool if it should loop forever - will change that to loopcount in the future<br>
```` **returns:** self<br>
**parameters:** [endlessloop] - bool if it should loop forever - will change that to loopcount in the future<br>
**returns:** self<br> ## cancel
cancels the animation
## cancel ````lua
cancels the animation local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local testButton = mainFrame:addButton("myTestButton"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setBackground(colors.black) end):wait(1):add(function() aAnimation:cancel() end):wait(1):add(function() testButton:setBackground(colors.lightGray) end)
local testButton = mainFrame:addButton("myTestButton"):show()
local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setBackground(colors.black) end):wait(1):add(function() aAnimation:cancel() end):wait(1):add(function() testButton:setBackground(colors.lightGray) end) aAnimation:play()
````
aAnimation:play() **parameters:** -<br>
````
**parameters:** -<br>
**returns:** self<br> **returns:** self<br>

View File

@@ -1,80 +1,78 @@
# Basalt Basalt is managing all the things.
Basalt is managing all the things. To start using Basalt you have to do the following line of code:
To start using Basalt you have to do the following line of code: `local basalt = dofile("basalt.lua")`
`local basalt = dofile("basalt.lua")` remember you need the basalt.lua file on your computer!
remember you need the basalt.lua file on your computer! Now you are able to call all these functions:
Now you are able to call all these functions: ## basalt.createFrame
create a frame without a parent
## basalt.createFrame ````lua
create a frame without a parent local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua ````
local mainFrame = basalt.createFrame("myFirstFrame"):show() **parameters:** string name<br>
```` **returns:** new frame object<br>
**parameters:** string name<br>
**returns:** new frame object<br> ## basalt.removeFrame
removes a frame (only possible for non-parent frames)
## basalt.removeFrame ````lua
removes a frame (only possible for non-parent frames) local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua basalt.removeFrame("myFirstFrame")
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
basalt.removeFrame("myFirstFrame") **parameters:** string name<br>
```` **returns:**-<br>
**parameters:** string name<br>
**returns:**-<br> ## basalt.getFrame
With that function you can get frames, but only frames without a parent!
## basalt.getFrame ````lua
With that function you can get frames, but only frames without a parent! basalt.createFrame("myFirstFrame")
````lua basalt.getFrame("myFirstFrame"):show()
basalt.createFrame("myFirstFrame") ````
basalt.getFrame("myFirstFrame"):show() **parameters:** string name<br>
```` **returns:** frame object<br>
**parameters:** string name<br>
**returns:** frame object<br> ## basalt.getActiveFrame
returns the currently active (without a parent) frame
## basalt.getActiveFrame ````lua
returns the currently active (without a parent) frame basalt.createFrame("myFirstFrame"):show()
````lua basalt.debug(basalt.getActiveFrame():getName()) -- returns myFirstFrame
basalt.createFrame("myFirstFrame"):show() ````
basalt.debug(basalt.getActiveFrame():getName()) -- returns myFirstFrame **parameters:** -<br>
```` **returns:** frame object<br>
**parameters:** -<br>
**returns:** frame object<br> ## basalt.autoUpdate
starts the draw and event handler until you use basalt.stopUpdate
## basalt.autoUpdate ````lua
starts the draw and event handler until you use basalt.stopUpdate local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua basalt.autoUpdate()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
basalt.autoUpdate() **parameters:** -<br>
```` **returns:**-<br>
**parameters:** -<br>
**returns:**-<br> ## basalt.update
calls the draw and event handler method once
## basalt.update ````lua
calls the draw and event handler method once local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua basalt.autoUpdate()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
basalt.autoUpdate() **parameters:** string event, ... (you can use some paramters here. you dont have to pass any paramters )<br>
```` **returns:**-<br>
**parameters:** string event, ... (you can use some paramters here. you dont have to pass any paramters )<br>
**returns:**-<br> ## basalt.stopUpdate
stops the draw and event handler
## basalt.stopUpdate ````lua
stops the draw and event handler basalt.stopUpdate()
````lua ````
basalt.stopUpdate() **parameters:** -<br>
```` **returns:**-<br>
**parameters:** -<br>
**returns:**-<br> ## basalt.debug
creates a label with some information on the main frame on the bottom left, if you click on that label it will open a log view for you see it as the new print for debugging
## basalt.debug ````lua
creates a label with some information on the main frame on the bottom left, if you click on that label it will open a log view for you see it as the new print for debugging basalt.debug("Hi i am cute")
````lua ````
basalt.debug("Hi i am cute") **parameters:** ... (multiple parameters are possible, like print does)<br>
```` **returns:**-<br>
**parameters:** ... (multiple parameters are possible, like print does)<br>
**returns:**-<br>

View File

@@ -1,25 +1,24 @@
# Button Buttons are objects, which execute function by clicking on them
Buttons are objects, which execute function by clicking on them The following list is only available to buttons: <br>
Remember button also inherits from [object](https://github.com/NoryiE/basalt/wiki/Object):
The following list is only available to buttons: <br>
Remember button also inherits from [object](/objects/Object): ## setText
Sets the displayed button text
## setText ````lua
Sets the displayed button text local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):show() -- you could also use :setValue() instead of :setText() - no difference
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):show() -- you could also use :setValue() instead of :setText() - no difference **Arguments:** string text<br>
```` **returns:** self<br>
**Arguments:** string text<br>
**returns:** self<br> # Examples
Add a onClick event:
## Examples ````lua
Add a onClick event: local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):onClick(function(self,event,button,x,y)
local mainFrame = basalt.createFrame("myFirstFrame"):show() if(event=="mouse_click")and(button==1)then
local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):onClick(function(self,event,button,x,y) basalt.debug("Left mousebutton got clicked!")
if(event=="mouse_click")and(button==1)then end
basalt.debug("Left mousebutton got clicked!") end):show()
end ````
end):show()

View File

@@ -1,14 +1,13 @@
# Checkbox With checkbox, the user can set a bool to true or false
With checkbox, the user can set a bool to true or false Here are all possible functions available for checkbox:<be>
Remember checkbox inherits from [object](https://github.com/NoryiE/NyoUI/wiki/Object):
Here are all possible functions available for checkbox:<be>
Remember checkbox inherits from [object](/objects/Object):
Create a onChange event:
````lua
Create a onChange event: local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):onChange(function(self) basalt.debug("The value got changed into "..self:getValue()) end):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):onChange(function(self) basalt.debug("The value got changed into "..self:getValue()) end):show() ````
````

View File

@@ -1,180 +1,178 @@
# Dropdown Dropdowns 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
Dropdowns 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 dropdown:
Here is a example of how to create a standard dropdown: ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
```` Here are all possible functions available for dropdowns: <br>
Remember dropdown inherits from [object](https://github.com/NoryiE/basalt/wiki/Object):
Here are all possible functions available for dropdowns: <br>
Remember dropdown inherits from [object](/objects/Object): ## addItem
Adds a item to the dropdown
## addItem
Adds a item to the dropdown ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aDropdown:addItem("1. Entry")
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show() aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("1. Entry") aDropdown:addItem("3. Entry",colors.yellow,colors.green)
aDropdown:addItem("2. Entry",colors.yellow) ````
aDropdown:addItem("3. Entry",colors.yellow,colors.green) **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)<br>
```` **returns:** self<br>
**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)<br>
**returns:** self<br> ## removeItem
Removes a item from the dropdown
## removeItem
Removes a item from the dropdown ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aDropdown:addItem("1. Entry")
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show() aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("1. Entry") aDropdown:addItem("3. Entry",colors.yellow,colors.green)
aDropdown:addItem("2. Entry",colors.yellow) aDropdown:removeItem(2)
aDropdown:addItem("3. Entry",colors.yellow,colors.green) ````
aDropdown:removeItem(2) **parameters:** number index<br>
```` **returns:** self<br>
**parameters:** number index<br>
**returns:** self<br> ## editItem
Edits a item on the dropdown
## editItem
Edits a item on the dropdown ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aDropdown:addItem("1. Entry")
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show() aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("1. Entry") aDropdown:addItem("3. Entry",colors.yellow,colors.green)
aDropdown:addItem("2. Entry",colors.yellow) aDropdown:editItem(3,"3. Edited Entry",colors.yellow,colors.green)
aDropdown:addItem("3. Entry",colors.yellow,colors.green) ````
aDropdown:editItem(3,"3. Edited Entry",colors.yellow,colors.green) **parameters:** number index, string text, number bgcolor, number fgcolor, any ...<br>
```` **returns:** self<br>
**parameters:** number index, string text, number bgcolor, number fgcolor, any ...<br>
**returns:** self<br> ## setScrollable
Makes the dropdown scrollable
## setScrollable
Makes the dropdown scrollable ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aDropdown:addItem("1. Entry")
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show() aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("1. Entry") aDropdown:addItem("3. Entry",colors.yellow,colors.green)
aDropdown:addItem("2. Entry",colors.yellow) aDropdown:setScrollable(true)
aDropdown:addItem("3. Entry",colors.yellow,colors.green) ````
aDropdown:setScrollable(true) **parameters:** boolean isScrollable<br>
```` **returns:** self<br>
**parameters:** boolean isScrollable<br>
**returns:** self<br> ## selectItem
selects a item in the dropdown (same as a player would click on a item)
## selectItem
selects a item in the dropdown (same as a player would click on a item) ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aDropdown:addItem("1. Entry")
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show() aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("1. Entry") aDropdown:addItem("3. Entry",colors.yellow,colors.green)
aDropdown:addItem("2. Entry",colors.yellow) aDropdown:selectItem(1)
aDropdown:addItem("3. Entry",colors.yellow,colors.green) ````
aDropdown:selectItem(1) **parameters:** number index<br>
```` **returns:** self<br>
**parameters:** number index<br>
**returns:** self<br> ## clear
clears the entire list (dropdown)
## clear
clears the entire list (dropdown) ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aDropdown:addItem("1. Entry")
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show() aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("1. Entry") aDropdown:addItem("3. Entry",colors.yellow,colors.green)
aDropdown:addItem("2. Entry",colors.yellow) aDropdown:clear()
aDropdown:addItem("3. Entry",colors.yellow,colors.green) ````
aDropdown:clear() **parameters:** -<br>
```` **returns:** self<br>
**parameters:** -<br>
**returns:** self<br> ## getItemIndex
returns the item index of the currently selected item
## getItemIndex
returns the item index of the currently selected item ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aDropdown:addItem("1. Entry")
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show() aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("1. Entry") aDropdown:addItem("3. Entry",colors.yellow,colors.green)
aDropdown:addItem("2. Entry",colors.yellow) aDropdown:getItemIndex()
aDropdown:addItem("3. Entry",colors.yellow,colors.green) ````
aDropdown:getItemIndex() **parameters:** -<br>
```` **returns:** number index<br>
**parameters:** -<br>
**returns:** number index<br> ## setSelectedItem
Sets the background of the item which is currently selected
## setSelectedItem
Sets the background of the item which is currently selected ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aDropdown:addItem("1. Entry")
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show() aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("1. Entry") aDropdown:addItem("3. Entry",colors.yellow,colors.green)
aDropdown:addItem("2. Entry",colors.yellow) aDropdown:setSelectedItem(colors.green, colors.blue)
aDropdown:addItem("3. Entry",colors.yellow,colors.green) ````
aDropdown: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>
**parameters:** number bgcolor, number fgcolor, boolean isActive (isActive means if different colors for selected item should be used)<br>
**returns:** self<br> ## setOffset
sets the dropdown offset (will automatically change if scrolling is active)
## setOffset
sets the dropdown offset (will automatically change if scrolling is active) ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aDropdown:addItem("1. Entry")
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show() aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("1. Entry") aDropdown:addItem("3. Entry",colors.yellow,colors.green)
aDropdown:addItem("2. Entry",colors.yellow) aDropdown:setOffset(3)
aDropdown:addItem("3. Entry",colors.yellow,colors.green) ````
aDropdown:setOffset(3) **parameters:** number offsetValue<br>
```` **returns:** self<br>
**parameters:** number offsetValue<br>
**returns:** self<br> ## getOffset
returns the current offset
## getOffset
returns the current offset ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aDropdown:addItem("1. Entry")
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show() aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("1. Entry") aDropdown:addItem("3. Entry",colors.yellow,colors.green)
aDropdown:addItem("2. Entry",colors.yellow) aDropdown:getOffset()
aDropdown:addItem("3. Entry",colors.yellow,colors.green) ````
aDropdown:getOffset() **parameters:** -<br>
```` **returns:** number offsetValue<br>
**parameters:** -<br>
**returns:** number offsetValue<br> ## getOffset
returns the current offset
## getOffset
returns the current offset ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aDropdown:addItem("1. Entry")
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show() aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("1. Entry") aDropdown:addItem("3. Entry",colors.yellow,colors.green)
aDropdown:addItem("2. Entry",colors.yellow) aDropdown:getOffset()
aDropdown:addItem("3. Entry",colors.yellow,colors.green) ````
aDropdown:getOffset() **parameters:** -<br>
```` **returns:** number offsetValue<br>
**parameters:** -<br>
**returns:** number offsetValue<br> ## setDropdownSize
sets the dropdown size (if you click on the button)
## setDropdownSize
sets the dropdown size (if you click on the button) ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aDropdown:addItem("1. Entry")
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show() aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("1. Entry") aDropdown:addItem("3. Entry",colors.yellow,colors.green)
aDropdown:addItem("2. Entry",colors.yellow) aDropdown:setDropdownSize(12, 4)
aDropdown:addItem("3. Entry",colors.yellow,colors.green) ````
aDropdown:setDropdownSize(12, 4) **parameters:** number width, number height<br>
````
**parameters:** number width, number height<br>
**returns:** self<br> **returns:** self<br>

View File

@@ -1,159 +1,227 @@
# Frames <a href="https://i.imgur.com/aikc0K1.png"><img src="https://i.imgur.com/aikc0K1.png" height="500" /></a>
<a href="https://i.imgur.com/aikc0K1.png"><img src="https://i.imgur.com/aikc0K1.png" height="500" /></a> Frames are like containers, but are also normal objects.
In other words, you can add other objects _(even frames)_ to a frame; if the frame itself is visible
Frames are like containers, but are also normal objects. all sub-objects _(if they are set as visible)_ are also visible. A better description will follow.
In other words, you can add other objects _(even frames)_ to a frame; if the frame itself is visible
all sub-objects _(if they are set as visible)_ are also visible. A better description will follow. ## basalt.createFrame
Creates a new non-parent frame - in most cases it is the first thing you'll need.
## basalt.createFrame
Creates a new non-parent frame - in most cases it is the first thing you need. #### Parameters:
1. `string` name (should be unique)
````lua
local myFirstFrame = basalt.createFrame("myFirstFrame") #### Returns:
```` 1. `frame | nil` The frame created by createFrame, or `nil` if there is already a frame with the given name.
**Parameters:** <br>
1. string name (should be unique)<br> #### Usage:
**returns:** new frame object<br> * Create a frame with an id "myFirstFrame", stored in a variable named frame
````lua
## addFrame local myFrame = basalt.createFrame("myFirstFrame")
The same as basalt.createFrame, but it will have a parent frame ````
````lua
frame:addFrame("myFirstFrame") ## addFrame
```` Creates a child frame on the frame, the same as [basalt.createFrame](https://github.com/Pyroxenium/Basalt/wiki/Frame#basaltcreateframe) except the frames are given a parent-child relationship automatically
**Parameters:** string name (should be unique)<br>
**returns:** new frame object<br> #### Parameters:
Example: 1. `string` name (should be unique)
````lua
local mainFrame = basalt.createFrame("myFirstFrame") #### Returns:
local aFrame = mainFrame:addFrame("myFirstSubFrame") 1. `frame | nil` The frame created by addFrame, or `nil` if there is already a child frame with the given name.<br>
````
## setBar #### Usage:
Changes the frame bar * Create a frame with id "myFirstFrame" then create a child of that frame, named "myFirstSubFrame"
````lua ````lua
frame:setBar("My first Frame!", colors.gray, colors.lightGray) local mainFrame = basalt.createFrame("myFirstFrame")
```` local myFrame = mainFrame:addFrame("myFirstSubFrame")
**Parameters:** string text, number bgcolor, number fgcolor<br> ````
**returns:** self<br>
Example: ## setBar
````lua Sets the text, background, and foreground of the upper bar of the frame, accordingly.
local mainFrame = basalt.createFrame("myFirstFrame")
local aFrame = MainFrame:addFrame("myFirstSubFrame") #### Parameters:
aFrame:setBar("My first Frame!") 1. `string` The text to set the bar to
```` 2. `number` The background color
or: 2. `number` The foreground color
````lua
local mainFrame = basalt.createFrame("myFirstFrame") #### Returns:
local aFrame = mainFrame:addFrame("myFirstSubFrame"):setBar("My first Frame!") 1. `frame` The frame being used
````
#### Usage:
## setBarTextAlign * Set the title to "My first frame!", with a background of gray and a foreground of light gray.
Sets the bar text alignment ````lua
````lua frame:setBar("My first Frame!", colors.gray, colors.lightGray)
local mainFrame = basalt.createFrame("myFirstFrame"):setBar("My first Frame!"):setBarTextAlign("right") ````
```` * Store the frame, use the named frame variable after assigning.
**Parameters:** string value - ("left", "center", "right"))<br> ````lua
**returns:** self<br> local mainFrame = basalt.createFrame("myFirstFrame")
local myFrame = MainFrame:addFrame("myFirstSubFrame")
myFrame:setBar("My first Frame!")
````
## showBar * This abuses the call-chaining that Basalt uses.
shows/hides the bar on top where you will see the title if its active ````lua
````lua local mainFrame = basalt.createFrame("myFirstFrame")
local mainFrame = basalt.createFrame("myFirstFrame"):setBar("Hello World!"):showBar() local myFrame = mainFrame:addFrame("myFirstSubFrame"):setBar("My first Frame!")
```` ````
**Parameters:** bool visible (no Parameters = true)<br>
**returns:** self<br> ## setBarTextAlign
Sets the frame's bar-text alignment
## isModifierActive -- DISABLED this function will work very soon
returns true if user is currently holding a key down #### Parameters:
````lua 1. `string` Can be supplied with "left", "center", or "right"
local mainFrame = basalt.createFrame("myFirstFrame"):isModifierActive("shift") #### Returns:
```` 1. `frame` The frame being used
**Parameters:** int or string - int can be any os.queueEvent("key") key, or instead of int you can use the following strings: "shift", "ctrl", "alt"<br> #### Usage:
**returns:** boolean - if the user is holding the key down<br> * Set the title of myFrame to "My first frame!", and align it to the right.
````lua
**Example:** local mainFrame = myFrame:setBar("My first Frame!"):setBarTextAlign("right")
````lua ````
local mainFrame = basalt.createFrame("myFirstFrame"):setSize(20,8):show()
local aLabel = mainFrame:addLabel("myFirstLabel"):setText("shift inactive") ## showBar
mainFrame:addButton("myFirstButton"):setText("Click"):onClick(function() Toggles the frame's upper bar
if(mainFrame:isModifierActive("shift")then #### Parameters:
aLabel:setText("shift is active yay") 1. `boolean | nil` Whether the frame's bar is visible or if supplied `nil`, is automatically visible
else #### Returns:
aLabel:setText("shift is not active ohno") 1. `frame` The frame being used
end) #### Usage:
```` * Sets myFrame to have a bar titled "Hello World!" and subsequently displays it.
````lua
## getObject local mainFrame = myFrame:setBar("Hello World!"):showBar()
returns a children object ````
````lua
local mainFrame = basalt.createFrame("myFirstFrame") ## ~~isModifierActive~~
mainFrame:addButton("myFirstButton") ### _Disabled, this function is a WIP_
local aButton = mainFrame:getObject("myFirstButton") Returns true if the user is currently holding the respective key down
````
**Parameters:** string name (has to be a children)<br> #### Parameters:
**returns:** any object<br> 1. `number | string` - Any os.queueEvent("key") key, or you can use the following strings: "shift", "ctrl", "alt"
#### Returns:
## removeObject 1. `boolean` - Whether the user is holding the key down
removes the object #### Usage:
````lua * Checks if the "shift" modifier is active on the myFrame frame
local mainFrame = basalt.createFrame("myFirstFrame") ````lua
mainFrame:addButton("myFirstButton") local isActive = myFrame:isModifierActive("shift")
mainFrame:removeObject("myFirstButton") ````
```` * Creates a label, changing the text to "Shift is inactive oh no :(" and "Shift is active yay!", accordingly.
**Parameters:** string name (has to be a children)<br> ````lua
**returns:** any object<br> local aLabel = myFrame:addLabel("myFirstLabel"):setText("Shift is inactive oh no :(")
myFrame:addButton("myFirstButton"):setText("Click"):onClick(
## setFocusedObject function()
changes the currently focused object if myFrame:isModifierActive("shift") then
````lua aLabel:setText("Shift is active yay!")
local mainFrame = basalt.createFrame("myFirstFrame") else
local aButton = mainFrame:addButton("myFirstButton") aLabel:setText("Shift is inactive oh no :(")
mainFrame:setFocusedObject(aButton) end
```` end
**Parameters:** any object (has to be a children)<br> )
**returns:** self<br> ````
## removeFocusedObject
removes the focus of the currently focused object ## getObject
````lua Returns a child object of the frame
local mainFrame = basalt.createFrame("myFirstFrame")
local aButton = mainFrame:addButton("myFirstButton") #### Parameters:
mainFrame:removeFocusedObject(aButton) 1. `string` The name of the child object
```` #### Returns:
**Parameters:** any object (has to be a children)<br> 1. `object | nil` The object with the supplied name, or `nil` if there is no object present with the given name
**returns:** self<br> #### Usage:
* Adds a button with id "myFirstButton", then retrieves it again through the frame object
## getFocusedObject ````lua
gets the currently focused object myFrame:addButton("myFirstButton")
````lua local aButton = myFrame:getObject("myFirstButton")
local mainFrame = basalt.createFrame("myFirstFrame") ````
local aButton = mainFrame:addButton("myFirstButton")
local focusedObject = mainFrame:getFocusedObject() ## removeObject
```` Removes a child object from the frame
**Parameters:** -<br> #### Parameters:
**returns:** object<br> 1. `string` The name of the child object
#### Returns:
## setMovable 1. `boolean` Whether the object with the given name was properly removed
#### Usage:
* Adds a button with the id "myFirstButton", then removes it with the aforementioned id
## setMoveable ````lua
##### _Deprecated in favor of setMovable_ myFrame:addButton("myFirstButton")
myFrame:removeObject("myFirstButton")
sets if the frame should be moveable or not (to move the frame you need to drag it on the top bar) ````
````lua ## setFocusedObject
local mainFrame = basalt.createFrame("myFirstFrame"):setMoveable(true) Sets the currently focused object
````
**Parameters:** bool moveable<br> #### Parameters:
**returns:** self<br> 1. `object` The child object to focus on
#### Returns:
## setOffset 1. `frame` The frame being used
sets the frame's coordinate offset, they will get added to their children objects. For example, if you use the scrollbar and you use its value to add a offset to a frame, you will get a scrollable frame. #### Usage:
objects are also able to ignore the offset by using :ignoreOffset() (maybe your scrollbar if its a children of the frame should ignore offset) * Creates button with id "myFirstButton", sets the focused object to the previously mentioned button
````lua
````lua local aButton = myFrame:addButton("myFirstButton")
local mainFrame = basalt.createFrame("myFirstFrame"):setOffset(5, 3) myFrame:setFocusedObject(aButton)
```` ````
**Parameters:** number x, number y (offset in x direction and offset in y direction, also doesn't matter if its a negative value or positive<br> ## removeFocusedObject
**returns:** self<br> Removes the focus of the supplied object
#### Parameters:
1. `object` The child object to remove focus from
#### Returns:
1. `frame` The frame being used
#### Usage:
* Creates a button with id "myFirstButton", then removes the focus from that button
````lua
local aButton = myFrame:addButton("myFirstButton")
myFrame:removeFocusedObject(aButton)
````
## getFocusedObject
Gets the currently focused object
#### Parameters:
#### Returns:
1. `object` The currently focused object
#### Usage:
* Gets the currently focused object from the frame, storing it in a variable
````lua
local focusedObject = myFrame:getFocusedObject()
````
## setMovable
Sets whether the frame can be moved. _In order to move the frame click and drag the upper bar of the frame_
#### Parameters:
1. `boolean` Whether the object is movable
#### Returns:
1. `frame` The frame being used
#### Usage:
* Creates a frame with id "myFirstFrame" and makes it movable
````lua
local myFrame = basalt.createFrame("myFirstFrame"):setMovable(true)
````
## ~~setMoveable~~
### _Deprecated in favor of setMovable_
Sets whether the frame can be moved. _In order to move the frame use the upper bar of the frame_
#### Parameters:
1. `boolean` Whether the object is movable
#### Returns:
1. `frame` The frame being used
#### Usage:
* Creates a frame with id "myFirstFrame" and makes it movable
````lua
local myFrame = basalt.createFrame("myFirstFrame"):setMoveable(true)
````
## setOffset
Sets the frame's coordinate offset. The frame's child objects will receive the frame's coordinate offset. For example, when using the scrollbar, if you use its value to add an offset to a frame, you will get a scrollable frame.
Objects are also able to ignore the offset by using :ignoreOffset() (For example, you may want to ignore the offset on the scrollbar itself)
The function can be supplied negative offsets
#### Parameters:
1. `number` The x direction offset (+/-)
2. `number` The y direction offset (+/-)
#### Returns:
1. `frame` The frame being used
#### Usage:
* Creates "myFirstFrame" with an x offset of 5 and a y offset of 3
````lua
local myFrame = basalt.createFrame("myFirstFrame"):setOffset(5, 3)
````
* Creates "myFirstFrame" with an x offset of 5 and a y offset of -5 (Meaning if you added a button with y position 5, it would be at y position 0)
````lua
local myFrame = basalt.createFrame("myFirstFrame"):setOffset(5, -5)
````

View File

@@ -1,37 +1,36 @@
# Image The image object is for adding more advanced backgrounds.
It also provides a :shrink() function, where you can shrink the images to smaller ones. This functionallity is fully provided by the blittle library created by Bomb Bloke. I did not ask for permission to add it into the framework. If the creator wants me to remove the blittle part, just text me on discord!
The image object is for adding more advanced backgrounds.
It also provides a :shrink() function, where you can shrink the images to smaller ones. This functionallity is fully provided by the blittle library created by Bomb Bloke. I did not ask for permission to add it into the framework. If the creator wants me to remove the blittle part, just text me on discord! Here are all possible functions available for image:<be>
Remember image inherits from [object](https://github.com/NoryiE/NyoUI/wiki/Object):
Here are all possible functions available for image:<be>
Remember image inherits from [object](/objects/Object):
## loadImage
loads a image into the memory.
## loadImage ````lua
loads a image into the memory. local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aImage = mainFrame:addImage("myFirstImage"):loadImage("randomImage.nfp"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aImage = mainFrame:addImage("myFirstImage"):loadImage("randomImage.nfp"):show() **Arguments:** string path<br>
```` **returns:** self<br>
**Arguments:** string path<br>
**returns:** self<br>
## loadBlittleImage -- not finished yet
loads a blittle image into the memory.
## loadBlittleImage -- not finished yet ````lua
loads a blittle image into the memory. local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aImage = mainFrame:addImage("myFirstImage"):loadBlittleImage("blittleImage.blt"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aImage = mainFrame:addImage("myFirstImage"):loadBlittleImage("blittleImage.blt"):show() **Arguments:** string path<br>
```` **returns:** self<br>
**Arguments:** string path<br>
**returns:** self<br> ## shrink
If you were loading a normal (paint) image into the memory, this function would shrink it to a
## shrink blittle image and immediatly draws it (if it's visible)
If you were loading a normal (paint) image into the memory, this function would shrink it to a ````lua
blittle image and immediatly draws it (if it's visible) local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aImage = mainFrame:addImage("myFirstImage"):loadBlittleImage("randomImage.nfp"):shrink():show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aImage = mainFrame:addImage("myFirstImage"):loadBlittleImage("randomImage.nfp"):shrink():show() **Arguments:** -<br>
```` **returns:** self<br>
**Arguments:** -<br>
**returns:** self<br>

View File

@@ -1,15 +1,13 @@
# Input With input's you are able to create a object where the user can type something in.<br>
With input's you are able to create a object where the user can type something in.<br> Here are all possible functions available for inputs:<br>
Remember input inherits from [object](https://github.com/NoryiE/NyoUI/wiki/Object):
Here are all possible functions available for inputs:<br>
Remember input inherits from [object](/objects/Object): ## setInputType
changes the input type
## setInputType ````lua
changes the input type local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aInput = mainFrame:addInput("myFirstInput"):setInputType("password"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aInput = mainFrame:addInput("myFirstInput"):setInputType("password"):show() **parameters:** string value ("text", "password", "number")<br>
```` **returns:** self<br>
**parameters:** string value ("text", "password", "number")<br>
**returns:** self<br>

73
docs/objects/Installer.md Normal file
View File

@@ -0,0 +1,73 @@
This is just a script which helps you to install basalt.lua, if it's not already on the computer. Means, you create your program (which requires basalt) and add this on the top of your program. Now, everytime you execute your program it checks if basalt.lua exists or not. If not, it will download it first and then continue to execute your program.
## Visual Installer
This is a visual version, it asks the user if he wants to install basalt.lua (if not found)<br>
![](https://i.imgur.com/b4Ys7FB.png)
````lua
--Basalt configurated installer
local filePath = "basalt.lua" --here you can change the file path default: basalt.lua
if not(fs.exists(filePath))then
local w,h = term.getSize()
term.clear()
local _installerWindow = window.create(term.current(),w/2-8,h/2-3,18,6)
_installerWindow.setBackgroundColor(colors.gray)
_installerWindow.setTextColor(colors.black)
_installerWindow.write(" Basalt Installer ")
_installerWindow.setBackgroundColor(colors.lightGray)
for line=2,6,1 do
_installerWindow.setCursorPos(1,line)
if(line==3)then
_installerWindow.write(" No Basalt found! ")
elseif(line==4)then
_installerWindow.write(" Install it? ")
elseif(line==6)then
_installerWindow.setTextColor(colors.black)
_installerWindow.setBackgroundColor(colors.gray)
_installerWindow.write("Install")
_installerWindow.setBackgroundColor(colors.lightGray)
_installerWindow.write(string.rep(" ",5))
_installerWindow.setBackgroundColor(colors.red)
_installerWindow.write("Cancel")
else
_installerWindow.write(string.rep(" ",18))
end
end
_installerWindow.setVisible(true)
_installerWindow.redraw()
while(not(fs.exists(filePath))) do
local event, p1,p2,p3,p4 = os.pullEvent()
if(event=="mouse_click")then
if(p3==math.floor(h/2+2))and(p2>=w/2-8)and(p2<=w/2-2)then
shell.run("pastebin run ESs1mg7P")
_installerWindow.setVisible(false)
term.clear()
break
end
if(p3==h/2+2)and(p2<=w/2+9)and(p2>=w/2+4)then
_installerWindow.clear()
_installerWindow.setVisible(false)
term.setCursorPos(1,1)
term.clear()
return
end
end
end
term.setCursorPos(1,1)
term.clear()
end
local basalt = dofile(filePath) -- here you can change the variablename in any variablename you want default: basalt
------------------------------
````
## Basic Installer
Here is a very basic one which just installs basalt.lua if don't exist:
````lua
--Basalt configurated installer
local filePath = "basalt.lua" --here you can change the file path default: basalt.lua
if not(fs.exists(filePath))then
shell.run("pastebin run ESs1mg7P")
end
local basalt = dofile(filePath) -- here you can change the variablename in any variablename you want default: basalt
````

View File

@@ -1,17 +1,34 @@
# Label With the Label object you are able to add some text.
With the Label object you are able to add some text. By default label's width is auto sizing based on the length of the text. If you change the size with setSize it will automatically stop autosizing the width.
By default label's width is auto sizing based on the length of the text. If you change the size with setSize it will automatically stop autosizing the width. Here are all possible functions available for labels.<br>
Remember label inherits from [object](https://github.com/NoryiE/NyoUI/wiki/Object):
Here are all possible functions available for labels.<br>
Remember label inherits from [object](/objects/Object): ## setText
sets the text which gets displayed.
## setText ````lua
sets the text which gets displayed. local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aInput = mainFrame:addLabel("myFirstLabel"):setText("Hello lovely basalt community!"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aInput = mainFrame:addLabel("myFirstLabel"):setText("Hello lovely basalt community!"):show() **arguments:** string text<br>
```` **returns:** self<br>
**arguments:** string text<br>
**returns:** self<br> ## setFontSize
sets the font size of that text.
````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aInput = mainFrame:addLabel("myFirstLabel"):setText("Hello"):setFontSize(2):show()
````
**arguments:** number size (1 = default, 2 = big, 3 = bigger, 4 = huge)<br>
**returns:** self<br>
## getFontSize
returns the fontsize
````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aInput = mainFrame:addLabel("myFirstLabel"):setText("Hello"):setFontSize(2):show()
basalt.debug(aInput:getFontSize()) -- returns 2
````
**arguments:** <br>
**returns:** number<br>

View File

@@ -1,153 +1,151 @@
# List Lists are objects where you can create endless entrys and the user can choose one of them
Lists are objects where you can create endless entrys and the user can choose one of them Here is a example of how to create a standard list:
Here is a example of how to create a standard list: ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aList = mainFrame:addList("myFirstList"):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 ">"
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/basalt/wiki/Object):
Here are all possible functions available for lists. Remember list inherit from [object](/objects/Object): ## addItem
Adds a item into the list
## addItem
Adds a item to the list ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aList = mainFrame:addList("myFirstList"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aList:addItem("1. Entry")
local aList = mainFrame:addList("myFirstList"):show() aList:addItem("2. Entry",colors.yellow)
aList:addItem("1. Entry") aList:addItem("3. Entry",colors.yellow,colors.green)
aList:addItem("2. Entry",colors.yellow) ````
aList:addItem("3. Entry",colors.yellow,colors.green) **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)<br>
```` **returns:** self<br>
**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)<br>
**returns:** self<br> ## removeItem
Removes a item from the list
## removeItem
Removes a item from the list ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aList = mainFrame:addList("myFirstList"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aList:addItem("1. Entry")
local aList = mainFrame:addList("myFirstList"):show() aList:addItem("2. Entry",colors.yellow)
aList:addItem("1. Entry") aList:addItem("3. Entry",colors.yellow,colors.green)
aList:addItem("2. Entry",colors.yellow) aList:removeItem(2)
aList:addItem("3. Entry",colors.yellow,colors.green) ````
aList:removeItem(2) **parameters:** number index<br>
```` **returns:** self<br>
**parameters:** number index<br>
**returns:** self<br> ## editItem
Edits a item on the list
## editItem
Edits a item on the list ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aList = mainFrame:addList("myFirstList"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aList:addItem("1. Entry")
local aList = mainFrame:addList("myFirstList"):show() aList:addItem("2. Entry",colors.yellow)
aList:addItem("1. Entry") aList:addItem("3. Entry",colors.yellow,colors.green)
aList:addItem("2. Entry",colors.yellow) aList:editItem(3,"3. Edited Entry",colors.yellow,colors.green)
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 ...<br>
```` **returns:** self<br>
**parameters:** number index, string text, number bgcolor, number fgcolor, any ...<br>
**returns:** self<br> ## setScrollable
Makes the list scrollable
## setScrollable
Makes the list scrollable ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aList = mainFrame:addList("myFirstList"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aList:addItem("1. Entry")
local aList = mainFrame:addList("myFirstList"):show() aList:addItem("2. Entry",colors.yellow)
aList:addItem("1. Entry") aList:addItem("3. Entry",colors.yellow,colors.green)
aList:addItem("2. Entry",colors.yellow) aList:setScrollable(true)
aList:addItem("3. Entry",colors.yellow,colors.green) ````
aList:setScrollable(true) **parameters:** boolean isScrollable<br>
```` **returns:** self<br>
**parameters:** boolean isScrollable<br>
**returns:** self<br> ## selectItem
selects a item in the list (same as a player would click on a item)
## selectItem
selects a item in the list (same as a player would click on a item) ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aList = mainFrame:addList("myFirstList"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aList:addItem("1. Entry")
local aList = mainFrame:addList("myFirstList"):show() aList:addItem("2. Entry",colors.yellow)
aList:addItem("1. Entry") aList:addItem("3. Entry",colors.yellow,colors.green)
aList:addItem("2. Entry",colors.yellow) aList:selectItem(1)
aList:addItem("3. Entry",colors.yellow,colors.green) ````
aList:selectItem(1) **parameters:** number index<br>
```` **returns:** self<br>
**parameters:** number index<br>
**returns:** self<br> ## clear
clears the entire list
## clear
clears the entire list ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aDropdown:addItem("1. Entry")
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show() aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("1. Entry") aDropdown:addItem("3. Entry",colors.yellow,colors.green)
aDropdown:addItem("2. Entry",colors.yellow) aDropdown:clear()
aDropdown:addItem("3. Entry",colors.yellow,colors.green) ````
aDropdown:clear() **parameters:** -<br>
```` **returns:** self<br>
**parameters:** -<br>
**returns:** self<br> ## getItemIndex
returns the item index of the currently selected item
## getItemIndex
returns the item index of the currently selected item ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aDropdown:addItem("1. Entry")
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show() aDropdown:addItem("2. Entry",colors.yellow)
aDropdown:addItem("1. Entry") aDropdown:addItem("3. Entry",colors.yellow,colors.green)
aDropdown:addItem("2. Entry",colors.yellow) aDropdown:getItemIndex()
aDropdown:addItem("3. Entry",colors.yellow,colors.green) ````
aDropdown:getItemIndex() **parameters:** -<br>
```` **returns:** number index<br>
**parameters:** -<br>
**returns:** number index<br> ## setSelectedItem
Sets the background of the item which is currently selected
## setSelectedItem
Sets the background of the item which is currently selected ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aList = mainFrame:addList("myFirstList"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aList:addItem("1. Entry")
local aList = mainFrame:addList("myFirstList"):show() aList:addItem("2. Entry",colors.yellow)
aList:addItem("1. Entry") aList:addItem("3. Entry",colors.yellow,colors.green)
aList:addItem("2. Entry",colors.yellow) aList:setSelectedItem(colors.green, colors.blue)
aList:addItem("3. Entry",colors.yellow,colors.green) ````
aList: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>
**parameters:** number bgcolor, number fgcolor, boolean isActive (isActive means if different colors for selected item should be used)<br>
**returns:** self<br> ## setOffset
sets the list offset (will automatically change if scrolling is active)
## setOffset
sets the list offset (will automatically change if scrolling is active) ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aList = mainFrame:addList("myFirstList"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aList:addItem("1. Entry")
local aList = mainFrame:addList("myFirstList"):show() aList:addItem("2. Entry",colors.yellow)
aList:addItem("1. Entry") aList:addItem("3. Entry",colors.yellow,colors.green)
aList:addItem("2. Entry",colors.yellow) aList:setOffset(3)
aList:addItem("3. Entry",colors.yellow,colors.green) ````
aList:setOffset(3) **parameters:** number offsetValue<br>
```` **returns:** self<br>
**parameters:** number offsetValue<br>
**returns:** self<br> ## getOffset
returns the current offset
## getOffset
returns the current offset ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aList = mainFrame:addList("myFirstList"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aList:addItem("1. Entry")
local aList = mainFrame:addList("myFirstList"):show() aList:addItem("2. Entry",colors.yellow)
aList:addItem("1. Entry") aList:addItem("3. Entry",colors.yellow,colors.green)
aList:addItem("2. Entry",colors.yellow) aList:getOffset()
aList:addItem("3. Entry",colors.yellow,colors.green) ````
aList:getOffset() **parameters:** -<br>
````
**parameters:** -<br>
**returns:** number offsetValue<br> **returns:** number offsetValue<br>

View File

@@ -1,3 +1 @@
# Menubar
WIP WIP

View File

@@ -1,249 +1,247 @@
# Objects This is the base class of all visual objects. This means, if you create a button, label, frame or something else visual (no timers, threads or animations) the following list can be used:
This is the base class of all visual objects. This means, if you create a button, label, frame or something else visual (no timers, threads or animations) the following list can be used: ## show
shows the object (only if the parent frame is already visible)
## show ````lua
shows the object (only if the parent frame is already visible) local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local button = mainFrame:addButton("myFirstButton")
local mainFrame = basalt.createFrame("myFirstFrame"):show() button:show()
local button = mainFrame:addButton("myFirstButton") ````
button:show() **parameters:** -<br>
```` **returns:** self<br>
**parameters:** -<br>
**returns:** self<br> ## hide
hides the object
## hide ````lua
hides the object local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local button = mainFrame:addButton("myFirstButton"):setText("Close"):onClick(function() mainFrame:hide() end)
local mainFrame = basalt.createFrame("myFirstFrame"):show() button:show()
local button = mainFrame:addButton("myFirstButton"):setText("Close"):onClick(function() mainFrame:hide() end) ````
button:show() **parameters:** -<br>
```` **returns:** self<br>
**parameters:** -<br>
**returns:** self<br> ## setPosition
Changes the position relative to its parent frame
## setPosition ````lua
Changes the position relative to its parent frame local mainFrame = basalt.createFrame("myFirstFrame"):setPosition(2,3)
````lua ````
local mainFrame = basalt.createFrame("myFirstFrame"):setPosition(2,3) **parameters:** number x, number y[, boolean relative], if relative is set to true it will add/remove instead of set x, y<br>
```` **returns:** self<br>
**parameters:** number x, number y[, boolean relative], if relative is set to true it will add/remove instead of set x, y<br>
**returns:** self<br>
## setBackground
Changes the object background color
## setBackground ````lua
Changes the object background color local mainFrame = basalt.createFrame("myFirstFrame"):setBackground(colors.lightGray)
````lua ````
local mainFrame = basalt.createFrame("myFirstFrame"):setBackground(colors.lightGray) **parameters:** number color<br>
```` **returns:** self<br>
**parameters:** number color<br>
**returns:** self<br> ## setForeground
Changes the object text color
## setForeground ````lua
Changes the object text color local mainFrame = basalt.createFrame("myFirstFrame"):setForeground(colors.black)
````lua ````
local mainFrame = basalt.createFrame("myFirstFrame"):setForeground(colors.black) **parameters:** number color<br>
```` **returns:** self<br>
**parameters:** number color<br>
**returns:** self<br> ## setSize
Changes the object size
## setSize ````lua
Changes the object size local mainFrame = basalt.createFrame("myFirstFrame"):setSize(15,5)
````lua ````
local mainFrame = basalt.createFrame("myFirstFrame"):setSize(15,5) **parameters:** number width, number length<br>
```` **returns:** self<br>
**parameters:** number width, number length<br>
**returns:** self<br> ## setFocus
sets the object to be the focused object.
## setFocus If you click on a object, it's normaly automatically the focused object. As example, if you :show() a frame and you want this particular frame to be in
sets the object to be the focused object. the foreground, you have to use :setFocus()
If you click on a object, it's normaly automatically the focused object. As example, if you :show() a frame and you want this particular frame to be in ````lua
the foreground, you have to use :setFocus() local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aButton = mainFrame:addButton("myFirstButton"):setFocus():show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aButton = mainFrame:addButton("myFirstButton"):setFocus():show() **parameters:** -<br>
```` **returns:** self<br>
**parameters:** -<br>
**returns:** self<br> ## setZIndex
changes the z index (higher z index do have higher draw/event priority) 10 is more important than 5 or 1. You are also able to add multiple objects to the same z index, which means if you create a couple of buttons, you set their z index to 10, everything below 10 is less important, everything above 10 is more important. On the same z index: the last object which gets created is the most important one.
## setZIndex ````lua
changes the z index (higher z index do have higher draw/event priority) 10 is more important than 5 or 1. You are also able to add multiple objects to the same z index, which means if you create a couple of buttons, you set their z index to 10, everything below 10 is less important, everything above 10 is more important. On the same z index: the last object which gets created is the most important one. local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aButton = mainFrame:addButton("myFirstButton"):setZIndex(1):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aButton = mainFrame:addButton("myFirstButton"):setZIndex(1):show() **parameters:** number index<br>
```` **returns:** self<br>
**parameters:** number index<br>
**returns:** self<br> ## setParent
changes the frame parent of that object
## setParent ````lua
changes the frame parent of that object local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aRandomFrame = basalt.createFrame("aRandomFrame"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() local aButton = mainFrame:addButton("myFirstButton"):onClick(function() aRandomFrame:setParent(mainFrame) end):show()
local aRandomFrame = basalt.createFrame("aRandomFrame"):show() ````
local aButton = mainFrame:addButton("myFirstButton"):onClick(function() aRandomFrame:setParent(mainFrame) end):show() **parameters:** frame object<br>
```` **returns:** self<br>
**parameters:** frame object<br>
**returns:** self<br> ## isFocused
returns if the object is currently the focused object of the parent frame
## isFocused
returns if the object is currently the focused object of the parent frame ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aButton = mainFrame:addButton("myFirstButton"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() basalt.debug(aButton:isFocused()) -- shows true or false as a debug message
local aButton = mainFrame:addButton("myFirstButton"):show() ````
basalt.debug(aButton:isFocused()) -- shows true or false as a debug message **parameters:** -<br>
```` **returns:** boolean<br>
**parameters:** -<br>
**returns:** boolean<br> ## getAnchorPosition
converts the x,y coordinates into the anchor coordinates of that object
## getAnchorPosition
converts the x,y coordinates into the anchor coordinates of that object ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):setSize(15,15):show()
````lua local aButton = mainFrame:addButton("myFirstButton"):setAnchor("right","bottom"):setSize(8,1):setPosition(1,1):show()
local mainFrame = basalt.createFrame("myFirstFrame"):setSize(15,15):show() basalt.debug(aButton:getAnchorPosition()) -- returns 7,14 (framesize - own size) instead of 1,1
local aButton = mainFrame:addButton("myFirstButton"):setAnchor("right","bottom"):setSize(8,1):setPosition(1,1):show() ````
basalt.debug(aButton:getAnchorPosition()) -- returns 7,14 (framesize - own size) instead of 1,1 **parameters:** number x, number y - or nothing (if nothing it uses the object's x, y)<br>
```` **returns:** number x, number y (converted)<br>
**parameters:** number x, number y - or nothing (if nothing it uses the object's x, y)<br>
**returns:** number x, number y (converted)<br> ## setAnchor
sets the anchor of that object
## setAnchor
sets the anchor of that object ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):setAnchor("right"):show()
````lua local aButton = mainFrame:addButton("myFirstButton"):setAnchor("bottom","right"):setSize(8,1):setPosition(1,1):show()
local mainFrame = basalt.createFrame("myFirstFrame"):setAnchor("right"):show() ````
local aButton = mainFrame:addButton("myFirstButton"):setAnchor("bottom","right"):setSize(8,1):setPosition(1,1):show() **parameters:** string sides - ("left", "right", "top", "bottom") you can stack positions like so ..:setAnchor("right", "bottom")<br>
```` **returns:** self<br>
**parameters:** string sides - ("left", "right", "top", "bottom") you can stack positions like so ..:setAnchor("right", "bottom")<br>
**returns:** self<br> ## getAbsolutePosition
converts the relative coordinates into absolute coordinates
## getAbsolutePosition ````lua
converts the relative coordinates into absolute coordinates local mainFrame = basalt.createFrame("myFirstFrame"):setPosition(3,3):show()
````lua local aButton = mainFrame:addButton("myFirstButton"):setSize(8,1):setPosition(4,2):show()
local mainFrame = basalt.createFrame("myFirstFrame"):setPosition(3,3):show() basalt.debug(aButton:getAbsolutePosition()) -- returns 7,5 (frame coords + own coords) instead of 4,2
local aButton = mainFrame:addButton("myFirstButton"):setSize(8,1):setPosition(4,2):show() ````
basalt.debug(aButton:getAbsolutePosition()) -- returns 7,5 (frame coords + own coords) instead of 4,2 **parameters:** number x, number y - or nothing (if nothing it uses the object's x, y)<br>
```` **returns:** self<br>
**parameters:** number x, number y - or nothing (if nothing it uses the object's x, y)<br>
**returns:** self<br> ## setTextAlign
sets the text align of the object (for example buttons)
## setTextAlign ````lua
sets the text align of the object (for example buttons) local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aButton = mainFrame:addButton("myFirstButton"):setSize(12,3):setTextAlign("right", "center"):setText("Dont't..."):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aButton = mainFrame:addButton("myFirstButton"):setSize(12,3):setTextAlign("right", "center"):setText("Dont't..."):show() **parameters:** string horizontal, string vertical - ("left", "center", "right")<br>
```` **returns:** self<br>
**parameters:** string horizontal, string vertical - ("left", "center", "right")<br>
**returns:** self<br> ## setValue
sets the value of that object (input, label, checkbox, textfield, scrollbar,...)
## setValue ````lua
sets the value of that object (input, label, checkbox, textfield, scrollbar,...) local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show() **parameters:** any value<br>
```` **returns:** self<br>
**parameters:** any value<br>
**returns:** self<br> ## getValue
returns the currently saved value
## getValue ````lua
returns the currently saved value local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() basalt.debug(aCheckbox:getValue()) -- returns true
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show() ````
basalt.debug(aCheckbox:getValue()) -- returns true **parameters:**-<br>
```` **returns:** any value<br>
**parameters:**-<br>
**returns:** any value<br> ## getHeight/getWidth
returns the height or width
## getHeight/getWidth ````lua
returns the height or width local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aButton = mainFrame:addButton("myFirstButton"):setSize(5,8):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() basalt.debug(aButton:getHeight()) -- returns 8
local aButton = mainFrame:addButton("myFirstButton"):setSize(5,8):show() ````
basalt.debug(aButton:getHeight()) -- returns 8 **parameters:**-<br>
```` **returns:** number height/width<br>
**parameters:**-<br>
**returns:** number height/width<br> ## isVisible
returns if the object is currently visible
## isVisible ````lua
returns if the object is currently visible local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aButton = mainFrame:addButton("myFirstButton"):setSize(5,8):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() basalt.debug(aButton:isVisible()) -- returns true
local aButton = mainFrame:addButton("myFirstButton"):setSize(5,8):show() ````
basalt.debug(aButton:isVisible()) -- returns true **parameters:**-<br>
```` **returns:** boolean<br>
**parameters:**-<br>
**returns:** boolean<br> ## getName
returns the given name of that object
## getName ````lua
returns the given name of that object local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua basalt.debug(mainFrame:getName()) -- returns myFirstFrame
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
basalt.debug(mainFrame:getName()) -- returns myFirstFrame **parameters:**-<br>
```` **returns:** string name<br>
**parameters:**-<br>
**returns:** string name<br> # Object Events
These object events are available for all objects, if a object got some unique events, you can see them in their own category
# Object Events
These object events are available for all objects, if a object got some unique events, you can see them in their own category ## onClick
creates a mouse_click event
## onClick ````lua
creates a mouse_click event local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClick(function(self,event,button,x,y) basalt.debug("Hellooww UwU") end):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClick(function(self,event,button,x,y) basalt.debug("Hellooww UwU") end):show() **parameters:** function func<br>
```` **returns:** self<br>
**parameters:** function func<br>
**returns:** self<br> ## onClickUp
creates a click_up event
## onClickUp ````lua
creates a click_up event local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClickUp(function(self,event,button,x,y) basalt.debug("Byeeeee UwU") end):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClickUp(function(self,event,button,x,y) basalt.debug("Byeeeee UwU") end):show() **parameters:** function func<br>
```` **returns:** self<br>
**parameters:** function func<br>
**returns:** self<br> ## onMouseDrag
creates a mouse_drag event
## onMouseDrag ````lua
creates a mouse_drag event local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClickUp(function(self,event,button,x,y) basalt.debug("Byeeeee UwU") end):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClickUp(function(self,event,button,x,y) basalt.debug("Byeeeee UwU") end):show() **parameters:** function func<br>
```` **returns:** self<br>
**parameters:** function func<br>
**returns:** self<br> ## onChange
creates a change event (fires as soon as the value gets changed)
## onChange ````lua
creates a change event (fires as soon as the value gets changed) local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):onChange(function(self) basalt.debug("i got changed into "..self:getValue()) end):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):onChange(function(self) basalt.debug("i got changed into "..self:getValue()) end):show() **parameters:** function func<br>
```` **returns:** self<br>
**parameters:** function func<br>
**returns:** self<br> ## onKey
creates a key(board) - event can be key or char
## onKey ````lua
creates a key(board) - event can be key or char local mainFrame = basalt.createFrame("myFirstFrame"):onKey(function(self,event,key) basalt.debug("you clicked "..key) end):show()
````lua ````
local mainFrame = basalt.createFrame("myFirstFrame"):onKey(function(self,event,key) basalt.debug("you clicked "..key) end):show() **parameters:** function func<br>
```` **returns:** self<br>
**parameters:** function func<br>
**returns:** self<br> ## onLoseFocus
creates a lose focus event
## onLoseFocus ````lua
creates a lose focus event local mainFrame = basalt.createFrame("myFirstFrame"):onLoseFocus(function(self) basalt.debug("please come back..") end):show()
````lua ````
local mainFrame = basalt.createFrame("myFirstFrame"):onLoseFocus(function(self) basalt.debug("please come back..") end):show() **parameters:** function func<br>
```` **returns:** self<br>
**parameters:** function func<br>
**returns:** self<br> ## onGetFocus
creates a get focus event
## onGetFocus ````lua
creates a get focus event local mainFrame = basalt.createFrame("myFirstFrame"):onGetFocus(function(self) basalt.debug("thanks!") end):show()
````lua ````
local mainFrame = basalt.createFrame("myFirstFrame"):onGetFocus(function(self) basalt.debug("thanks!") end):show() **parameters:** function func<br>
````
**parameters:** function func<br>
**returns:** self<br> **returns:** self<br>

View File

@@ -1,18 +1,16 @@
# Pane Panes are very simple sizeable background objects.
Panes are very simple sizeable background objects. The following list is only available to panes: <br>
Remember pane also inherits from [object](https://github.com/NoryiE/basalt/wiki/Object):
The following list is only available to panes: <br>
Remember pane also inherits from [object](/objects/Object): Pane doesn't have any custom functionallity. If you want to change the color/position or size, just check out the [object](https://github.com/NoryiE/basalt/wiki/Object) wikipage.
Pane doesn't have any custom functionallity. If you want to change the color/position or size, just check out the [object](/objects/Object) wikipage. ## Example:
## Example: ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aPane = mainFrame:addPane("myFirstBackground")
local mainFrame = basalt.createFrame("myFirstFrame"):show() aPane:setSize(30, 10)
local aPane = mainFrame:addPane("myFirstBackground") aPane:setBackground(colors.yellow)
aPane:setSize(30, 10) aPane:show()
aPane:setBackground(colors.yellow)
aPane:show()
```` ````

View File

@@ -1,104 +1,103 @@
# Program With a program object you are able to open programs like shell or worm or any custom program you've made. There is only 1 thing you have to remember: the program needs at least one os.sleep() or coroutine.yield() somewhere.
<br>
With a program object you are able to open programs like shell or worm or any custom program you've made. There is only 1 thing you have to remember: the program needs at least one os.sleep() or coroutine.yield() somewhere. Here is a list of all available functions for programs: <br>
<br> Remember program inherits from [object](https://github.com/NoryiE/NyoUI/wiki/Object):
Here is a list of all available functions for programs: <br>
Remember program inherits from [object](/objects/Object): ## getStatus
returns the current status
## getStatus ````lua
returns the current status local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aProgram = mainFrame:addProgram("myFirstProgram"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() basalt.debug(aProgram:getStatus()) -- returns "running", "normal", "suspended" or "dead"
local aProgram = mainFrame:addProgram("myFirstProgram"):show() ````
basalt.debug(aProgram:getStatus()) -- returns "running", "normal", "suspended" or "dead" **parameters:**-<br>
```` **returns:** string "running" - if its running, "normal" - is active but not running (waiting for a event), "suspended" - is suspended or not started, "dead" - has finished or stopped with an error<br>
**parameters:**-<br>
**returns:** string "running" - if its running, "normal" - is active but not running (waiting for a event), "suspended" - is suspended or not started, "dead" - has finished or stopped with an error<br> ## execute
executes the given path (-program)
## execute ````lua
executes the given path (-program) local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aProgram = mainFrame:addProgram("myFirstProgram"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aProgram:execute("rom/programs/fun/worm.lua") -- executes worm
local aProgram = mainFrame:addProgram("myFirstProgram"):show() ````
aProgram:execute("rom/programs/fun/worm.lua") -- executes worm **parameters:** string filepath - (the path to the program you want to execute)<br>
```` **returns:** self<br>
**parameters:** string filepath - (the path to the program you want to execute)<br>
**returns:** self<br> ## stop
gives a terminate event to the program, which means if you are running a shell, and the shell executes a program by itself you have to call stop 2 times to entirely close the running program
## stop ````lua
gives a terminate event to the program, which means if you are running a shell, and the shell executes a program by itself you have to call stop 2 times to entirely close the running program local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() mainFrame:addButton("myFirstButton"):setText("close"):onClick(function() aProgram:stop() end):show()
local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
mainFrame:addButton("myFirstButton"):setText("close"):onClick(function() aProgram:stop() end):show() ````
**parameters:**-<br>
```` **returns:** self<br>
**parameters:**-<br>
**returns:** self<br> ## pause
pauses the program (prevents the program from receiving events)
## pause ````lua
pauses the program (prevents the program from receiving events) local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() mainFrame:addButton("myFirstButton"):setText("close"):onClick(function() aProgram:pause(true) end):show()
local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
mainFrame:addButton("myFirstButton"):setText("close"):onClick(function() aProgram:pause(true) end):show() ````
**parameters:** boolean pause<br>
```` **returns:** self<br>
**parameters:** boolean pause<br>
**returns:** self<br> ## isPaused
returns if the program is currently paused
## isPaused ````lua
returns if the program is currently paused local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() mainFrame:addButton("myFirstButton"):setText("pause"):onClick(function() basalt.debug(aProgram:isPaused()) end):show()
local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
mainFrame:addButton("myFirstButton"):setText("pause"):onClick(function() basalt.debug(aProgram:isPaused()) end):show() ````
**parameters:** -<br>
```` **returns:** boolean isPaused<br>
**parameters:** -<br>
**returns:** boolean isPaused<br> ## injectEvent
injects a event into the program manually
## injectEvent ````lua
injects a event into the program manually local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() mainFrame:addButton("myFirstButton"):setText("inject"):onClick(function() aProgram:injectEvent("char", "w") end):show()
local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
mainFrame:addButton("myFirstButton"):setText("inject"):onClick(function() aProgram:injectEvent("char", "w") end):show() ````
**parameters:** string event, any parameter, any parameter, any parameter, any parameter, boolean ignorePause<br>
```` **returns:** self<br>
**parameters:** string event, any parameter, any parameter, any parameter, any parameter, boolean ignorePause<br>
**returns:** self<br> ## injectEvents
injects a event table into the program manually
## injectEvents ````lua
injects a event table into the program manually local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() --example will follow
local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
--example will follow ````
**parameters:** string event, any parameter, any parameter, any parameter, any parameter, boolean ignorePause<br>
```` **returns:** self<br>
**parameters:** string event, any parameter, any parameter, any parameter, any parameter, boolean ignorePause<br>
**returns:** self<br> ## getQueuedEvents
returns a table of all currently queued events (while pause is active incomming events will go into a queueEvents table) as soon as the program gets unpaused
## getQueuedEvents it will inject these events
returns a table of all currently queued events (while pause is active incomming events will go into a queueEvents table) as soon as the program gets unpaused ````lua
it will inject these events local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() mainFrame:addButton("myFirstButton"):setText("inject"):onClick(function() basalt.debug(aProgram:getQueuedEvents()) end):show()
local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
mainFrame:addButton("myFirstButton"):setText("inject"):onClick(function() basalt.debug(aProgram:getQueuedEvents()) end):show() ````
**parameters:** -<br>
```` **returns:** table queuedEvents<br>
**parameters:** -<br>
**returns:** table queuedEvents<br> ## updateQueuedEvents
here you can manipulate the queuedEvents table with your own events table
## updateQueuedEvents ````lua
here you can manipulate the queuedEvents table with your own events table local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() --example will follow
local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
--example will follow ````
**parameters:** table queuedEvents<br>
```` **returns:** self<br>
**parameters:** table queuedEvents<br>
**returns:** self<br>

View File

@@ -1,124 +1,122 @@
# Radio 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
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:
Here is a example of how to create a standard radio: ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aRadio = mainFrame:addRadio("myFirstRadio"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aRadio = mainFrame:addRadio("myFirstRadio"):show()
```` Here are all possible functions available for radios: <br>
Remember radio inherits from [object](https://github.com/NoryiE/basalt/wiki/Object):
Here are all possible functions available for radios: <br>
Remember radio inherits from [object](/objects/Object): ## addItem
Adds a item to the radio
## addItem
Adds a item to the radio ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aRadio = mainFrame:addRadio("myFirstRadio"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aRadio:addItem("1. Entry",3,4)
local aRadio = mainFrame:addRadio("myFirstRadio"):show() aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("1. Entry",3,4) aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
aRadio:addItem("2. Entry",3,5,colors.yellow) ````
aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green) **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>
**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 from the radio
## removeItem
Removes a item from the radio ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aRadio = mainFrame:addRadio("myFirstRadio"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aRadio:addItem("1. Entry",3,4)
local aRadio = mainFrame:addRadio("myFirstRadio"):show() aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("1. Entry",3,4) aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
aRadio:addItem("2. Entry",3,5,colors.yellow) aRadio:removeItem(2)
aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green) ````
aRadio:removeItem(2) **parameters:** number index<br>
```` **returns:** self<br>
**parameters:** number index<br>
**returns:** self<br> ## editItem
Edits a item on the radio
## editItem
Edits a item on the radio ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aRadio = mainFrame:addRadio("myFirstRadio"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aRadio:addItem("1. Entry",3,4)
local aRadio = mainFrame:addRadio("myFirstRadio"):show() aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("1. Entry",3,4) aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
aRadio:addItem("2. Entry",3,5,colors.yellow) aRadio:editItem(3,"3. Edited Entry",3,6,colors.yellow,colors.green)
aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green) ````
aRadio:editItem(3,"3. Edited Entry",3,6,colors.yellow,colors.green) **parameters:** number index, string text, number x, number y, number bgcolor, number fgcolor, any ...<br>
```` **returns:** self<br>
**parameters:** number index, string text, number x, number y, number bgcolor, number fgcolor, any ...<br>
**returns:** self<br> ## setScrollable
Makes the radio scrollable
## setScrollable
Makes the radio scrollable ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aRadio = mainFrame:addRadio("myFirstRadio"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aRadio:addItem("1. Entry",3,4)
local aRadio = mainFrame:addRadio("myFirstRadio"):show() aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("1. Entry",3,4) aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
aRadio:addItem("2. Entry",3,5,colors.yellow) aRadio:setScrollable(true)
aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green) ````
aRadio:setScrollable(true) **parameters:** boolean isScrollable<br>
```` **returns:** self<br>
**parameters:** boolean isScrollable<br>
**returns:** self<br> ## selectItem
selects a item in the radio (same as a player would click on a item)
## selectItem
selects a item in the radio (same as a player would click on a item) ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aRadio = mainFrame:addRadio("myFirstRadio"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aRadio:addItem("1. Entry",3,4)
local aRadio = mainFrame:addRadio("myFirstRadio"):show() aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("1. Entry",3,4) aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
aRadio:addItem("2. Entry",3,5,colors.yellow) aRadio:selectItem(1)
aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green) ````
aRadio:selectItem(1) **parameters:** number index<br>
```` **returns:** self<br>
**parameters:** number index<br>
**returns:** self<br> ## clear
clears the entire list (radio)
## clear
clears the entire list (radio) ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aRadio = mainFrame:addRadio("myFirstRadio"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aRadio:addItem("1. Entry",3,4)
local aRadio = mainFrame:addRadio("myFirstRadio"):show() aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("1. Entry",3,4) aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
aRadio:addItem("2. Entry",3,5,colors.yellow) aRadio:clear()
aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green) ````
aRadio:clear() **parameters:** -<br>
```` **returns:** self<br>
**parameters:** -<br>
**returns:** self<br> ## getItemIndex
returns the item index of the currently selected item
## getItemIndex
returns the item index of the currently selected item ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aRadio = mainFrame:addRadio("myFirstRadio"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aRadio:addItem("1. Entry",3,4)
local aRadio = mainFrame:addRadio("myFirstRadio"):show() aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("1. Entry",3,4) aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
aRadio:addItem("2. Entry",3,5,colors.yellow) aRadio:getItemIndex()
aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green) ````
aRadio:getItemIndex() **parameters:** -<br>
```` **returns:** number index<br>
**parameters:** -<br>
**returns:** number index<br> ## setSelectedItem
Sets the background of the item which is currently selected
## setSelectedItem
Sets the background of the item which is currently selected ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aRadio = mainFrame:addRadio("myFirstRadio"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aRadio:addItem("1. Entry",3,4)
local aRadio = mainFrame:addRadio("myFirstRadio"):show() aRadio:addItem("2. Entry",3,5,colors.yellow)
aRadio:addItem("1. Entry",3,4) aRadio:addItem("3. Entry",3,6,colors.yellow,colors.green)
aRadio:addItem("2. Entry",3,5,colors.yellow) aRadio:setSelectedItem(colors.green, colors.blue)
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>
````
**parameters:** number bgcolor, number fgcolor, boolean isActive (isActive means if different colors for selected item should be used)<br>
**returns:** self<br> **returns:** self<br>

View File

@@ -1,53 +1,48 @@
# Scrollbar Scrollbars are objects, the user can scroll vertically or horizontally, this can change the value.<br>
Here is a example of how to create a standard scrollbar:
Scrollbars are objects, the user can scroll vertically or horizontally, this can change the value.<br>
Here is a example of how to create a standard scrollbar: ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aScrollbar = mainFrame:addScrollbar("myFirstScrollbar"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aScrollbar = mainFrame:addScrollbar("myFirstScrollbar"):show() Here are all possible functions available for scrollbars. Remember scrollbar inherit from [object](https://github.com/NoryiE/Basalt/wiki/Object):
````
## setSymbol
This will create a default label with a size 5 width and 1 height on position 1 1 (relative to its parent frame), the default background is colors.gray, the default text color is colors.black. the default bar type is vertical, the default symbol is " " and the default symbol color is colors.lightGray. The default zIndex is 5. Changes the symbol
Here are all possible functions available for scrollbars. Remember scrollbar inherit from [object](/objects/Object): ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
## setSymbol local aScrollbar = mainFrame:addScrollbar("myFirstScrollbar"):setSymbol("X"):show()
Changes the symbol ````
**parameters:** char symbol<br>
````lua **returns:** self<br>
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aScrollbar = mainFrame:addScrollbar("myFirstScrollbar"):setSymbol("X"):show() ## setBackgroundSymbol
```` Changes the background symbol color
**parameters:** char symbol<br>
**returns:** self<br> ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
## setBackgroundSymbol local aScrollbar = mainFrame:addScrollbar("myFirstScrollbar"):setSymbol("X"):setBackgroundSymbol(colors.green):show()
Changes the background symbol color ````
**parameters:** number symbolcolor<br>
````lua **returns:** self<br>
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aScrollbar = mainFrame:addScrollbar("myFirstScrollbar"):setSymbol("X"):setBackgroundSymbol(colors.green):show() ## setBarType
```` If the bar goes vertically or horizontally
**parameters:** number symbolcolor<br>
**returns:** self<br> ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
## setBarType local aScrollbar = mainFrame:addScrollbar("myFirstScrollbar"):setBarType("horizontal"):show()
If the bar goes vertically or horizontally ````
**parameters:** string value ("vertical" or "horizontal")<br>
````lua **returns:** self<br>
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aScrollbar = mainFrame:addScrollbar("myFirstScrollbar"):setBarType("horizontal"):show() ## setMaxValue
```` the default max value is always the width (if horizontal) or height (if vertical), if you change the max value the bar will always calculate the value based on its width or height - example: you set the max value to 100, the height is 10 and it is a vertical bar, this means if the bar is on top, the value is 10, if the bar goes one below, it is 20 and so on.
**parameters:** string value ("vertical" or "horizontal")<br>
**returns:** self<br> ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
## setMaxValue local aScrollbar = mainFrame:addScrollbar("myFirstScrollbar"):setMaxValue(123):show()
the default max value is always the width (if vertical) or height (if horizontal), if you change the max value the bar will always calculate the value based on its width or height - example: you set the max value to 100, the height is 10 and it is a vertical bar, this means if the bar is on top, the value is 10, if the bar goes one below, it is 20 and so on. ````
**parameters:** any number<br>
````lua **returns:** self<br>
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aScrollbar = mainFrame:addScrollbar("myFirstScrollbar"):setMaxValue(123):show()
````
**parameters:** any number<br>
**returns:** self<br>

View File

@@ -1,42 +1,42 @@
# Slider With sliders you can add a object where the user can change a number value.<br><br>
With sliders you can add a object where the user can change a number value.<br><br> Here are all possible functions available for sliders: <br>
Remember slider also inherits from [object](https://github.com/NoryiE/Basalt/wiki/Object)
Here are all possible functions available for sliders: <br>
Remember slider also inherits from [object](/objects/Object) ## setSymbol
this will change the foreground symbol
## setSymbol ````lua
this will change the foreground symbol local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aSlider = mainFrame:addSlider("myFirstSlider"):setSymbol("X"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aSlider = mainFrame:addSlider("myFirstSlider"):setSymbol("X"):show() **parameters:** char symbol<br>
```` **returns:** self<br>
**parameters:** char symbol<br>
**returns:** self<br> ## setBackgroundSymbol
this will change the symbol background color
## setBackgroundSymbol ````lua
this will change the symbol background color local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aSlider = mainFrame:addSlider("myFirstSlider"):setBackgroundSymbol(colors.yellow):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aSlider = mainFrame:addSlider("myFirstSlider"):setBackgroundSymbol(colors.yellow):show() **parameters:** number color<br>
```` **returns:** self<br>
**parameters:** number color<br>
**returns:** self<br> ## setSymbolColor
this will change the symbol color
## setSymbolColor ````lua
this will change the symbol color local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aSlider = mainFrame:addSlider("myFirstSlider"):setSymbolColor(colors.red):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aSlider = mainFrame:addSlider("myFirstSlider"):setSymbolColor(colors.red):show() **parameters:** number color<br>
```` **returns:** self<br>
**parameters:** number color<br>
**returns:** self<br> ## setBarType
this will change the bar to vertical/horizontal (default is horizontal)
## setBarType ````lua
this will change the bar to vertical/horizontal (default is horizontal) local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aSlider = mainFrame:addSlider("myFirstSlider"):setBarType("vertical"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aSlider = mainFrame:addSlider("myFirstSlider"):setBarType("vertical"):show() **parameters:** string value ("vertical", "horizontal"<br>
```` **returns:** self<br>
**parameters:** string value ("vertical", "horizontal"<br>
**returns:** self<br>

View File

@@ -1,74 +1,72 @@
# Textfield Textfields are objects, where the user can write something on multiple lines. it act's like the default edit script (without coloring)<br>
Here is a example of how to create a default textfield:
Textfields are objects, where the user can write something on multiple lines. it act's like the default edit script (without coloring)<br>
Here is a example of how to create a default textfield: ````lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() ````
local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show()
```` This will create a default textfield with the size 10 width and 4 height on position 1 1 (relative to its parent frame), the default background is colors.gray, the default text color is colors.black and the default zIndex is 5.
This will create a default textfield with the size 10 width and 4 height on position 1 1 (relative to its parent frame), the default background is colors.gray, the default text color is colors.black and the default zIndex is 5. A list of all possible functions available for textfields. Remember textfield inherits from [object](https://github.com/NoryiE/NyoUI/wiki/Object):
A list of all possible functions available for textfields. Remember textfield inherits from [object](/objects/Object):
## getLines
returns all lines
## getLines ````lua
returns all lines local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() basalt.debug(aTextfield:getLines())
local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show() ````
basalt.debug(aTextfield:getLines()) **parameters:** -<br>
```` **returns:** table lines<br>
**parameters:** -<br>
**returns:** table lines<br> ## getLine
returns the line on index position
## getLine ````lua
returns the line on index position local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() basalt.debug(aTextfield:getLine(2))
local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show() ````
basalt.debug(aTextfield:getLine(2)) **parameters:** number index<br>
```` **returns:** string line<br>
**parameters:** number index<br>
**returns:** string line<br> ## editLine
edits line on index position
## editLine ````lua
edits line on index position local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aTextfield:editLine(2, "hellow")
local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show() ````
aTextfield:editLine(2, "hellow") **parameters:** number index, string text<br>
```` **returns:** self<br>
**parameters:** number index, string text<br>
**returns:** self<br> ## addLine
adds a line on index position (if index is nil it just adds the line on the bottom)
## addLine ````lua
adds a line on index position (if index is nil it just adds the line on the bottom) local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aTextfield:addLine("hellow")
local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show() ````
aTextfield:addLine("hellow") **parameters:** string text, number index<br>
```` **returns:** self<br>
**parameters:** string text, number index<br>
**returns:** self<br> ## removeLine
removes the line on index position
## removeLine ````lua
removes the line on index position local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() aTextfield:removeLine(1)
local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show() ````
aTextfield:removeLine(1) **parameters:** number index<br>
```` **returns:** self<br>
**parameters:** number index<br>
**returns:** self<br> ## getTextCursor
returns the cursor position
## getTextCursor ````lua
returns the cursor position local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() basalt.debug(aTextfield:getTextCursor())
local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show() ````
basalt.debug(aTextfield:getTextCursor()) **parameters:** -<br>
````
**parameters:** -<br>
**returns:** number x, number y<br> **returns:** number x, number y<br>

View File

@@ -1,49 +1,47 @@
# Thread Threads are "functions" you can execute simultaneously. Ofc the reality is, i am just using coroutine for that. But it works pretty good AND is very easy to use.
<br>
Threads are "functions" you can execute simultaneously. Ofc the reality is, i am just using coroutine for that. But it works pretty good AND is very easy to use. Here is a list of all available functions for threads: <br>
<br>
Here is a list of all available functions for threads: <br> ## start
starts a new thread and executes the function
## start ````lua
starts a new thread and executes the function local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aThread = mainFrame:addThread("myFirstThread"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() local function randomThreadFunction()
local aThread = mainFrame:addThread("myFirstThread"):show() while true do
local function randomThreadFunction() basalt.debug("Thread is active")
while true do os.sleep(1) -- a sleep/coroutine.yield() or pullEvent is required otherwise we will never come back to the main program (error)
basalt.debug("Thread is active") end
os.sleep(1) -- a sleep/coroutine.yield() or pullEvent is required otherwise we will never come back to the main program (error) end
end aThread:start(randomThreadfunction)
end ````
aThread:start(randomThreadfunction) **parameters:**function func<br>
```` **returns:** self<br>
**parameters:**function func<br>
**returns:** self<br> ## getStatus
gets the thread status
## getStatus ````lua
gets the thread status local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aThread = mainFrame:addThread("myFirstThread"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() basalt.debug(aThread:getStatus()) -- returns "running", "normal", "suspended" or "dead"
local aThread = mainFrame:addThread("myFirstThread"):show() ````
basalt.debug(aThread:getStatus()) -- returns "running", "normal", "suspended" or "dead" **parameters:** -<br>
```` **returns:** string "running" - if its running, "normal" - is active but not running (waiting for a event), "suspended" - is suspended<br>
**parameters:** -<br>
**returns:** string "running" - if its running, "normal" - is active but not running (waiting for a event), "suspended" - is suspended<br> ## stop
stops the thread
## stop ````lua
stops the thread local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aThread = mainFrame:addThread("myFirstThread"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show() local function randomThreadFunction()
local aThread = mainFrame:addThread("myFirstThread"):show() while true do
local function randomThreadFunction() basalt.debug("Thread is active")
while true do os.sleep(1) -- a sleep/coroutine.yield() or pullEvent is required otherwise we will never come back to the main program (error)
basalt.debug("Thread is active") end
os.sleep(1) -- a sleep/coroutine.yield() or pullEvent is required otherwise we will never come back to the main program (error) end
end aThread:start(randomThreadfunction)
end local aButton = mainFrame:addButton("myFirstButton"):setText("Stop Thread"):onClick(function() aThread:stop() end):show()
aThread:start(randomThreadfunction)
local aButton = mainFrame:addButton("myFirstButton"):setText("Stop Thread"):onClick(function() aThread:stop() end):show() ````
**parameters:** -<br>
````
**parameters:** -<br>
**returns:** self<br> **returns:** self<br>

View File

@@ -1,51 +1,49 @@
# Timer With timers you can call delayed functions.
<br>
With timers you can call delayed functions. Here is a list of all available functions for timers: <br>
<br>
Here is a list of all available functions for timers: <br> ## setTime
sets the time the timer should wait after calling your function
## setTime ````lua
sets the time the timer should wait after calling your function local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aTimer = mainFrame:addTimer("myFirstTimer")
local mainFrame = basalt.createFrame("myFirstFrame"):show() aTimer:setTime(5)
local aTimer = mainFrame:addTimer("myFirstTimer") ````
aTimer:setTime(5) **parameters:**number time[, number repeats] - (time in seconds, if repeats is -1 it will call the function infinitly (every x seconds)<br>
```` **returns:** self<br>
**parameters:**number time[, number repeats] - (time in seconds, if repeats is -1 it will call the function infinitly (every x seconds)<br>
**returns:** self<br> ## start
starts the timer
## start ````lua
starts the timer local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aTimer = mainFrame:addTimer("myFirstTimer")
local mainFrame = basalt.createFrame("myFirstFrame"):show() aTimer:setTime(5):start()
local aTimer = mainFrame:addTimer("myFirstTimer") ````
aTimer:setTime(5):start() **parameters:** -<br>
```` **returns:** self<br>
**parameters:** -<br>
**returns:** self<br> ## cancel
stops/cancels the timer
## cancel ````lua
stops/cancels the timer local mainFrame = basalt.createFrame("myFirstFrame"):show()
````lua local aTimer = mainFrame:addTimer("myFirstTimer")
local mainFrame = basalt.createFrame("myFirstFrame"):show() aTimer:setTime(5):start()
local aTimer = mainFrame:addTimer("myFirstTimer") aTimer:cancel()
aTimer:setTime(5):start() ````
aTimer:cancel() **parameters:** -<br>
```` **returns:** self<br>
**parameters:** -<br>
**returns:** self<br>
## onCall
adds a function to the timer
## onCall ````lua
adds a function to the timer local function timerCall(self)
````lua basalt.debug("i got called!")
local function timerCall(self) end
basalt.debug("i got called!") local mainFrame = basalt.createFrame("myFirstFrame"):show()
end local aTimer = mainFrame:addTimer("myFirstTimer")
local mainFrame = basalt.createFrame("myFirstFrame"):show() aTimer:setTime(5):onCall(timerCall):start()
local aTimer = mainFrame:addTimer("myFirstTimer")
aTimer:setTime(5):onCall(timerCall):start() ````
**parameters:** function func<br>
```` **returns:** self<br>
**parameters:** function func<br>
**returns:** self<br>

View File

@@ -1,41 +1,41 @@
# Changing button colors Here I want to explain to you how you would create a button with the default color gray, and as long as the user is clicking on the button it will change its color to black (the default frame-background is lightGray).
Here i want to explain to you how you would create a button with the default color gray, and as long as the user is clicking on the button it will change its color to black (the default frame-background is lightGray). To make this possible the button needs 1 onClick event, 1 onClickUp event and 1 onLoseFocus event.
To make this possible the button needs 1 onClick event, 1 onClickUp event and 1 onLoseFocus event. Very interesting sidetip: events can hold multiple functions!<br>
**Example snippet:**
Very interesting sidetip: events can hold multiple functions!<br> ````lua
**Example snippet:** local function buttonColoring()
````lua -- here you can add some coloring for your button
local function buttonColoring() end
-- here you can add some coloring for your button local function buttonLogic()
end -- here you can add some logic for your button
local function buttonLogic() end
-- here you can add some logic for your button local button = mainFrame:addButton("ExampleButton"):show()
end button:onClick(buttonColoring):onClick(buttonLogic) -- yes this would work, if not its a bug!
local button = mainFrame:addButton("ExampleButton"):show() ````
button:onClick(buttonColoring):onClick(buttonLogic) -- yes this would work, if not its a bug!
```` This means you can create a function wich handles only the coloring side of your button, and if your button also needs some logic you just create your own unique function for that and add it to your button.
This means you can create a function wich handles only the coloring side of your button, and if your button also needs some logic you just create your own unique function for that and add it to your button. With this knowledge we create now a function where we pass a button-object as parameter and this will setup the coloring of our button:
With this knowledge we create now a function where we pass a button-object as parameter and this will setup the coloring of our button: **Example snippet:**
````lua
**Example snippet:** local basalt = dofile("basalt.lua")
````lua local mainFrame = basalt.createFrame("mainFrame"):show()
local basalt = dofile("basalt.lua") local button = mainFrame:addButton("firstButton"):setPosition(3,3):setSize(12,3):setText("Click me"):setBackground(colors.gray):setForeground(colors.black):show()
local mainFrame = basalt.createFrame("mainFrame"):show()
local button = mainFrame:addButton("firstButton"):setPosition(3,3):setSize(12,3):setText("Click me"):setBackground(colors.gray):setForeground(colors.black):show() local button2 = mainFrame:addButton("secondButton"):setPosition(25,3):setSize(16,3):setText("Another Btn"):setBackground(colors.gray):setForeground(colors.black):show()
local button2 = mainFrame:addButton("secondButton"):setPosition(25,3):setSize(16,3):setText("Another Btn"):setBackground(colors.gray):setForeground(colors.black):show() local function setupButtonColoring(btn)
btn:onClick(function() btn:setBackground(colors.black) btn:setForeground(colors.lightGray) end)
local function setupButtonColoring(btn) btn:onClickUp(function() btn:setBackground(colors.gray) btn:setForeground(colors.black) end)
btn:onClick(function() btn:setBackground(colors.black) btn:setForeground(colors.lightGray) end) btn:onLoseFocus(function() btn:setBackground(colors.gray) btn:setForeground(colors.black) end)
btn:onClickUp(function() btn:setBackground(colors.gray) btn:setForeground(colors.black) end) end
btn:onLoseFocus(function() btn:setBackground(colors.gray) btn:setForeground(colors.black) end) setupButtonColoring(button)
end setupButtonColoring(button2)
setupButtonColoring(button)
setupButtonColoring(button2) basalt.autoUpdate()
````
basalt.autoUpdate()
```` Now you've got a function which sets your buttons up.

View File

@@ -1,57 +1,56 @@
# Executing your own logic You question yourself how you can execute your own logic while basalt is also active? There are multiple ways of doing that:
You question yourself how you can execute your own logic while basalt is also active? There are multiple ways of doing that: ## Method 1:
Using parallel.waitForAll
## Number 1:
Using parallel.waitForAll ````lua
local basalt = dofile("basalt.lua")
````lua
local basalt = dofile("basalt.lua") local mainFrame = basalt.createFrame("mainFrame"):show()-- lets create a frame and a button without functionality
mainFrame:addButton("aButton"):onClick(function() end):show()
local mainFrame = basalt.createFrame("mainFrame"):show()-- lets create a frame and a button without functionality
mainFrame:addButton("aButton"):onClick(function() end):show() local function yourCustomHandler()
while true do
local function yourCustomHandler() -- add your logic here
while true do os.sleep(1) -- you need something which calls coroutine.yield(), yes os.sleep does that os.pullEvent() aswell
-- add your logic here end
os.sleep(1) -- you need something which calls coroutine.yield(), yes os.sleep does that os.pullEvent() aswell end
end
end parallel.waitForAll(basalt.autoUpdate, yourCustomHandler) -- here it will handle your function (yourCustomHandler) and basalts handlers at the time
````
parallel.waitForAll(basalt.autoUpdate, yourCustomHandler) -- here it will handle your function (yourCustomHandler) and basalts handlers at the time You can read [here](http://www.computercraft.info/wiki/Parallel_(API)) what exactly parallel.waitForAll() does
````
You can read [here](http://www.computercraft.info/wiki/Parallel_(API)) what exactly parallel.waitForAll() does ## Method 2:
Using threads
## Number 2:
Using threads ````lua
local basalt = dofile("basalt.lua")
````lua
local basalt = dofile("basalt.lua") local mainFrame = basalt.createFrame("mainFrame"):show()-- lets create a frame, a button without functionality and a thread
mainFrame:addButton("aButton"):onClick(function() end):show()
local mainFrame = basalt.createFrame("mainFrame"):show()-- lets create a frame, a button without functionality and a thread local thread = mainFrame:addThread("customHandlerExecutingThread")
mainFrame:addButton("aButton"):onClick(function() end):show()
local thread = mainFrame:addThread("customHandlerExecutingThread") local function yourCustomHandler()
while true do
local function yourCustomHandler() -- add your logic here
while true do os.sleep(1) -- you need something which calls coroutine.yield(), yes os.sleep does that os.pullEvent() aswell
-- add your logic here end
os.sleep(1) -- you need something which calls coroutine.yield(), yes os.sleep does that os.pullEvent() aswell end
end thread:start(yourCustomHandler) -- this will create a coroutine and starts the coroutine, os.sleep does the rest, so you just have to call start once.
end ````
thread:start(yourCustomHandler) -- this will create a coroutine and starts the coroutine, os.sleep does the rest, so you just have to call start once.
```` ## Method 3:
Using timers
## Number 3:
Using timers ````lua
local basalt = dofile("basalt.lua")
````lua
local basalt = dofile("basalt.lua") local mainFrame = basalt.createFrame("mainFrame"):show()-- lets create a frame, a button without functionality and a timer
mainFrame:addButton("aButton"):onClick(function() end):show()
local mainFrame = basalt.createFrame("mainFrame"):show()-- lets create a frame, a button without functionality and a timer local timer = mainFrame:addTimer("customHandlerExecutingTimer")
mainFrame:addButton("aButton"):onClick(function() end):show()
local timer = mainFrame:addTimer("customHandlerExecutingTimer") local function yourCustomHandler()
-- add your logic here
local function yourCustomHandler() end
-- add your logic here timer:onCall(yourCustomHandler):setTime(1, -1):start() -- this will call your function every second until you :cancel() the timer
end ````
timer:onCall(yourCustomHandler):setTime(1, -1):start() -- this will call your function every second until you :cancel() the timer