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 ## show
shows the object (only if the parent frame is already visible) shows the object (only if the parent frame is already visible)
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.createFrame("myFirstFrame"):show()
local button = mainFrame:addButton("myFirstButton") local button = mainFrame:addButton("myFirstButton")
button:show() button:show()
```` ````
@@ -14,7 +14,7 @@ button:show()
## hide ## hide
hides the object hides the object
````lua ````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) local button = mainFrame:addButton("myFirstButton"):setText("Close"):onClick(function() mainFrame:hide() end)
button:show() button:show()
```` ````
@@ -24,7 +24,7 @@ button:show()
## setPosition ## setPosition
Changes the position relative to its parent frame Changes the position relative to its parent frame
````lua ````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> **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> **returns:** the frame object<br>
@@ -34,7 +34,7 @@ local mainFrame = NyoUI.createFrame("myFirstFrame"):setPosition(2,3)
## setBackground ## setBackground
Changes the object background color Changes the object background color
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):setBackground(colors.lightGray) local mainFrame = basalt.createFrame("myFirstFrame"):setBackground(colors.lightGray)
```` ````
**args:** int color<br> **args:** int color<br>
**returns:** the object<br> **returns:** the object<br>
@@ -42,7 +42,7 @@ local mainFrame = NyoUI.createFrame("myFirstFrame"):setBackground(colors.lightGr
## setForeground ## setForeground
Changes the object text color Changes the object text color
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):setForeground(colors.black) local mainFrame = basalt.createFrame("myFirstFrame"):setForeground(colors.black)
```` ````
**args:** int color<br> **args:** int color<br>
**returns:** the object<br> **returns:** the object<br>
@@ -50,7 +50,7 @@ local mainFrame = NyoUI.createFrame("myFirstFrame"):setForeground(colors.black)
## setSize ## setSize
Changes the object size Changes the object size
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):setSize(15,5) local mainFrame = basalt.createFrame("myFirstFrame"):setSize(15,5)
```` ````
**args:** width, length<br> **args:** width, length<br>
**returns:** the object<br> **returns:** the object<br>
@@ -58,7 +58,7 @@ local mainFrame = NyoUI.createFrame("myFirstFrame"):setSize(15,5)
## setFocus ## setFocus
sets the object to be the focused object sets the object to be the focused object
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setFocus():show() local aButton = mainFrame:addButton("myFirstButton"):setFocus():show()
```` ````
**args:** -<br> **args:** -<br>
@@ -67,7 +67,7 @@ local aButton = mainFrame:addButton("myFirstButton"):setFocus():show()
## setZIndex ## setZIndex
changes the z index (lower z index do have higher draw priority) changes the z index (lower z index do have higher draw priority)
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setZIndex(1):show() local aButton = mainFrame:addButton("myFirstButton"):setZIndex(1):show()
```` ````
**args:** index<br> **args:** index<br>
@@ -76,8 +76,8 @@ local aButton = mainFrame:addButton("myFirstButton"):setZIndex(1):show()
## setParent ## setParent
changes the frame parent of that object changes the frame parent of that object
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aRandomFrame = NyoUI.createFrame("aRandomFrame"):show() local aRandomFrame = basalt.createFrame("aRandomFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):onClick(function() aRandomFrame:setParent(mainFrame) end):show() local aButton = mainFrame:addButton("myFirstButton"):onClick(function() aRandomFrame:setParent(mainFrame) end):show()
```` ````
**args:** frame object<br> **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 returns if the object is currently the focused object of the parent frame
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):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> **args:** -<br>
**returns:** true or false<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 converts the x,y coordinates into the anchor coordinates of that object
````lua ````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() 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> **args:** x,y or nothing - if nothing it uses the object x,y<br>
**returns:** converted coordinates<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 sets the anchor of that object
````lua ````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() 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> **args:** "left", "right", "top", "bottom" - doesn't matter which order<br>
@@ -118,9 +118,9 @@ local aButton = mainFrame:addButton("myFirstButton"):setAnchor("bottom","right")
## relativeToAbsolutePosition ## relativeToAbsolutePosition
converts the relative coordinates into absolute coordinates converts the relative coordinates into absolute coordinates
````lua ````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() 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> **args:** x,y or nothing - if nothing it uses the object x,y<br>
**returns:** the object<br> **returns:** the object<br>
@@ -128,7 +128,7 @@ NyoUI.debug(aButton:relativeToAbsolutePosition()) -- returns 7,5 (frame coords +
## setTextAlign ## setTextAlign
sets the align of the object (as example buttons) sets the align of the object (as example buttons)
````lua ````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() 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> **args:** horizontal,vertical you can use "left", "center", "right"<br>
@@ -140,7 +140,7 @@ WIP
## setValue ## setValue
sets the value of that object (input, label, checkbox, textfield, scrollbar,...) sets the value of that object (input, label, checkbox, textfield, scrollbar,...)
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show() local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show()
```` ````
**args:** value (text,checked,number,...)<br> **args:** value (text,checked,number,...)<br>
@@ -149,9 +149,9 @@ local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show()
## getValue ## getValue
returns the currently saved value returns the currently saved value
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show() local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show()
NyoUI.debug(aCheckbox:getValue()) -- returns true basalt.debug(aCheckbox:getValue()) -- returns true
```` ````
**args:**-<br> **args:**-<br>
**returns:** the value<br> **returns:** the value<br>
@@ -165,9 +165,9 @@ WIP done but buggy have to look
## getHeight/getWidth ## getHeight/getWidth
returns the height or width of that object returns the height or width of that object
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(5,8):show() local aButton = mainFrame:addButton("myFirstButton"):setSize(5,8):show()
NyoUI.debug(aButton:getHeight()) -- returns 8 basalt.debug(aButton:getHeight()) -- returns 8
```` ````
**args:**-<br> **args:**-<br>
**returns:** returns the height or the width<br> **returns:** returns the height or the width<br>
@@ -175,9 +175,9 @@ NyoUI.debug(aButton:getHeight()) -- returns 8
## isVisible ## isVisible
returns if the object is currently visible returns if the object is currently visible
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(5,8):show() local aButton = mainFrame:addButton("myFirstButton"):setSize(5,8):show()
NyoUI.debug(aButton:isVisible()) -- returns true basalt.debug(aButton:isVisible()) -- returns true
```` ````
**args:**-<br> **args:**-<br>
**returns:** returns the visible state of that object<br> **returns:** returns the visible state of that object<br>
@@ -185,8 +185,8 @@ NyoUI.debug(aButton:isVisible()) -- returns true
## getName ## getName
returns the given name of that object returns the given name of that object
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.createFrame("myFirstFrame"):show()
NyoUI.debug(mainFrame:getName()) -- returns myFirstFrame basalt.debug(mainFrame:getName()) -- returns myFirstFrame
```` ````
**args:**-<br> **args:**-<br>
**returns:** returns the name<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 ## onClick
creates a mouse_click event creates a mouse_click event
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.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 aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClick(function(self,event,button,x,y) basalt.debug("Hellooww UwU") end):show()
```` ````
**args:** function<br> **args:** function<br>
**returns:** the object<br> **returns:** the object<br>
@@ -206,8 +206,8 @@ local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClick(funct
## onClickUp ## onClickUp
creates a click_up event creates a click_up event
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.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 aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClickUp(function(self,event,button,x,y) basalt.debug("Byeeeee UwU") end):show()
```` ````
**args:** function<br> **args:** function<br>
**returns:** the object<br> **returns:** the object<br>
@@ -215,8 +215,8 @@ local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClickUp(fun
## onMouseDrag ## onMouseDrag
creates a mouse_drag event creates a mouse_drag event
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.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 aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClickUp(function(self,event,button,x,y) basalt.debug("Byeeeee UwU") end):show()
```` ````
**args:** function<br> **args:** function<br>
**returns:** the object<br> **returns:** the object<br>
@@ -224,8 +224,8 @@ local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClickUp(fun
## onChange ## onChange
creates a change event (fires as soon as the value gets changed) creates a change event (fires as soon as the value gets changed)
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):onChange(function(self) NyoUI.debug("i got changed into "..self:getValue()) end):show() local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):onChange(function(self) basalt.debug("i got changed into "..self:getValue()) end):show()
```` ````
**args:** function<br> **args:** function<br>
**returns:** the object<br> **returns:** the object<br>
@@ -233,7 +233,7 @@ local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):onChange(function(sel
## onKey ## onKey
creates a key(board) - event can be key or char creates a key(board) - event can be key or char
````lua ````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> **args:** function<br>
**returns:** the object<br> **returns:** the object<br>
@@ -241,7 +241,7 @@ local mainFrame = NyoUI.createFrame("myFirstFrame"):onKey(function(self,event,ke
## onLoseFocus ## onLoseFocus
creates a lose focus event creates a lose focus event
````lua ````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> **args:** function<br>
**returns:** the object<br> **returns:** the object<br>
@@ -249,7 +249,7 @@ local mainFrame = NyoUI.createFrame("myFirstFrame"):onLoseFocus(function(self) N
## onGetFocus ## onGetFocus
creates a get focus event creates a get focus event
````lua ````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> **args:** function<br>
**returns:** the object<br> **returns:** the object<br>