Updated Object (markdown)

Robert Jelic
2022-04-24 16:04:48 +02:00
parent bd841a88b2
commit f5cb4cc84f

@@ -1,10 +1,10 @@
All the functions you can see here are available for all objects! It doesn't matter if its a frame or a button or a list (or something else).
All the functions you can see here are available for all visual objects! It doesn't matter if its a frame or a button or a list (or something else).
Here is a list of possible functions:
Here is a list of useable functions:
## show
shows the object (only if the parent frame is already visible)
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local button = mainFrame:addButton("myFirstButton")
button:show()
````
@@ -14,7 +14,7 @@ button:show()
## hide
hides the object
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local button = mainFrame:addButton("myFirstButton"):setText("Close"):onClick(function() mainFrame:hide() end)
button:show()
````
@@ -24,7 +24,7 @@ button:show()
## setPosition
Changes the position relative to its parent frame
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):setPosition(2,3)
local mainFrame = basalt.createFrame("myFirstFrame"):setPosition(2,3)
````
**args:** int x, int y[, "r"], "r" as third parameter means it will add x and y to current position instead of set it<br>
**returns:** the frame object<br>
@@ -34,7 +34,7 @@ local mainFrame = NyoUI.createFrame("myFirstFrame"):setPosition(2,3)
## setBackground
Changes the object background color
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):setBackground(colors.lightGray)
local mainFrame = basalt.createFrame("myFirstFrame"):setBackground(colors.lightGray)
````
**args:** int color<br>
**returns:** the object<br>
@@ -42,7 +42,7 @@ local mainFrame = NyoUI.createFrame("myFirstFrame"):setBackground(colors.lightGr
## setForeground
Changes the object text color
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):setForeground(colors.black)
local mainFrame = basalt.createFrame("myFirstFrame"):setForeground(colors.black)
````
**args:** int color<br>
**returns:** the object<br>
@@ -50,7 +50,7 @@ local mainFrame = NyoUI.createFrame("myFirstFrame"):setForeground(colors.black)
## setSize
Changes the object size
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):setSize(15,5)
local mainFrame = basalt.createFrame("myFirstFrame"):setSize(15,5)
````
**args:** width, length<br>
**returns:** the object<br>
@@ -58,7 +58,7 @@ local mainFrame = NyoUI.createFrame("myFirstFrame"):setSize(15,5)
## setFocus
sets the object to be the focused object
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setFocus():show()
````
**args:** -<br>
@@ -67,7 +67,7 @@ local aButton = mainFrame:addButton("myFirstButton"):setFocus():show()
## setZIndex
changes the z index (lower z index do have higher draw priority)
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setZIndex(1):show()
````
**args:** index<br>
@@ -76,8 +76,8 @@ local aButton = mainFrame:addButton("myFirstButton"):setZIndex(1):show()
## setParent
changes the frame parent of that object
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aRandomFrame = NyoUI.createFrame("aRandomFrame"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aRandomFrame = basalt.createFrame("aRandomFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):onClick(function() aRandomFrame:setParent(mainFrame) end):show()
````
**args:** frame object<br>
@@ -87,9 +87,9 @@ local aButton = mainFrame:addButton("myFirstButton"):onClick(function() aRandomF
returns if the object is currently the focused object of the parent frame
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):show()
NyoUI.debug(aButton:isFocusedObject()) -- shows true or false as a debug message
basalt.debug(aButton:isFocusedObject()) -- shows true or false as a debug message
````
**args:** -<br>
**returns:** true or false<br>
@@ -98,9 +98,9 @@ NyoUI.debug(aButton:isFocusedObject()) -- shows true or false as a debug message
converts the x,y coordinates into the anchor coordinates of that object
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):setSize(15,15):show()
local mainFrame = basalt.createFrame("myFirstFrame"):setSize(15,15):show()
local aButton = mainFrame:addButton("myFirstButton"):setAnchor("right","bottom"):setSize(8,1):setPosition(1,1):show()
NyoUI.debug(aButton:getAnchorPosition()) -- returns 7,14 (framesize - own size) instead of 1,1
basalt.debug(aButton:getAnchorPosition()) -- returns 7,14 (framesize - own size) instead of 1,1
````
**args:** x,y or nothing - if nothing it uses the object x,y<br>
**returns:** converted coordinates<br>
@@ -109,7 +109,7 @@ NyoUI.debug(aButton:getAnchorPosition()) -- returns 7,14 (framesize - own size)
sets the anchor of that object
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):setAnchor("right"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):setAnchor("right"):show()
local aButton = mainFrame:addButton("myFirstButton"):setAnchor("bottom","right"):setSize(8,1):setPosition(1,1):show()
````
**args:** "left", "right", "top", "bottom" - doesn't matter which order<br>
@@ -118,9 +118,9 @@ local aButton = mainFrame:addButton("myFirstButton"):setAnchor("bottom","right")
## relativeToAbsolutePosition
converts the relative coordinates into absolute coordinates
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):setPosition(3,3):show()
local mainFrame = basalt.createFrame("myFirstFrame"):setPosition(3,3):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(8,1):setPosition(4,2):show()
NyoUI.debug(aButton:relativeToAbsolutePosition()) -- returns 7,5 (frame coords + own coords) instead of 4,2
basalt.debug(aButton:relativeToAbsolutePosition()) -- returns 7,5 (frame coords + own coords) instead of 4,2
````
**args:** x,y or nothing - if nothing it uses the object x,y<br>
**returns:** the object<br>
@@ -128,7 +128,7 @@ NyoUI.debug(aButton:relativeToAbsolutePosition()) -- returns 7,5 (frame coords +
## setTextAlign
sets the align of the object (as example buttons)
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(12,3):setTextAlign("right", "center"):setText("Dont't..."):show()
````
**args:** horizontal,vertical you can use "left", "center", "right"<br>
@@ -140,7 +140,7 @@ WIP
## setValue
sets the value of that object (input, label, checkbox, textfield, scrollbar,...)
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show()
````
**args:** value (text,checked,number,...)<br>
@@ -149,9 +149,9 @@ local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show()
## getValue
returns the currently saved value
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show()
NyoUI.debug(aCheckbox:getValue()) -- returns true
basalt.debug(aCheckbox:getValue()) -- returns true
````
**args:**-<br>
**returns:** the value<br>
@@ -165,9 +165,9 @@ WIP done but buggy have to look
## getHeight/getWidth
returns the height or width of that object
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(5,8):show()
NyoUI.debug(aButton:getHeight()) -- returns 8
basalt.debug(aButton:getHeight()) -- returns 8
````
**args:**-<br>
**returns:** returns the height or the width<br>
@@ -175,9 +175,9 @@ NyoUI.debug(aButton:getHeight()) -- returns 8
## isVisible
returns if the object is currently visible
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(5,8):show()
NyoUI.debug(aButton:isVisible()) -- returns true
basalt.debug(aButton:isVisible()) -- returns true
````
**args:**-<br>
**returns:** returns the visible state of that object<br>
@@ -185,8 +185,8 @@ NyoUI.debug(aButton:isVisible()) -- returns true
## getName
returns the given name of that object
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
NyoUI.debug(mainFrame:getName()) -- returns myFirstFrame
local mainFrame = basalt.createFrame("myFirstFrame"):show()
basalt.debug(mainFrame:getName()) -- returns myFirstFrame
````
**args:**-<br>
**returns:** returns the name<br>
@@ -197,8 +197,8 @@ These object events are available for all objects, if a object got some unique e
## onClick
creates a mouse_click event
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClick(function(self,event,button,x,y) NyoUI.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()
````
**args:** function<br>
**returns:** the object<br>
@@ -206,8 +206,8 @@ local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClick(funct
## onClickUp
creates a click_up event
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClickUp(function(self,event,button,x,y) NyoUI.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()
````
**args:** function<br>
**returns:** the object<br>
@@ -215,8 +215,8 @@ local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClickUp(fun
## onMouseDrag
creates a mouse_drag event
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClickUp(function(self,event,button,x,y) NyoUI.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()
````
**args:** function<br>
**returns:** the object<br>
@@ -224,8 +224,8 @@ local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClickUp(fun
## onChange
creates a change event (fires as soon as the value gets changed)
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):onChange(function(self) NyoUI.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()
````
**args:** function<br>
**returns:** the object<br>
@@ -233,7 +233,7 @@ local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):onChange(function(sel
## onKey
creates a key(board) - event can be key or char
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):onKey(function(self,event,key) NyoUI.debug("you clicked "..key) end):show()
local mainFrame = basalt.createFrame("myFirstFrame"):onKey(function(self,event,key) basalt.debug("you clicked "..key) end):show()
````
**args:** function<br>
**returns:** the object<br>
@@ -241,7 +241,7 @@ local mainFrame = NyoUI.createFrame("myFirstFrame"):onKey(function(self,event,ke
## onLoseFocus
creates a lose focus event
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):onLoseFocus(function(self) NyoUI.debug("please come back..") end):show()
local mainFrame = basalt.createFrame("myFirstFrame"):onLoseFocus(function(self) basalt.debug("please come back..") end):show()
````
**args:** function<br>
**returns:** the object<br>
@@ -249,7 +249,7 @@ local mainFrame = NyoUI.createFrame("myFirstFrame"):onLoseFocus(function(self) N
## onGetFocus
creates a get focus event
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):onGetFocus(function(self) NyoUI.debug("thanks!") end):show()
local mainFrame = basalt.createFrame("myFirstFrame"):onGetFocus(function(self) basalt.debug("thanks!") end):show()
````
**args:** function<br>
**returns:** the object<br>