Updated Button (markdown)

Robert Jelic
2022-04-24 16:11:11 +02:00
parent 282cd84413
commit 8f34bb6f11

@@ -1,33 +1,33 @@
Buttons are objects, which execute function by clicking on them Buttons are objects, which execute function by clicking on them
Here is a example of how to create a standard button: Here is a example of how to create a standard button:
````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()
```` ````
This will create a default button with the size 5 width and 1 height on position 1 1 (relative to its parent frame), the default background is colors.lightBlue, the default text color is colors.black and the This will create a default button with the size 5 width and 1 height on position 1 1 (relative to its parent frame), the default background is colors.lightBlue, the default text color is colors.black and the
default zIndex is 5. The default vertical and horizontal text aligns are "center" - but there is no default text. default zIndex is 5. The default vertical and horizontal text aligns are "center" - but there is no default text.
Here are all possible functions available for buttons. Remember button inherit from [object](https://github.com/NoryiE/NyoUI/wiki/Object): Here are all possible functions available for buttons. Remember button inherit from [object](https://github.com/NoryiE/basalt/wiki/Object):
## setText ## setText
Sets the displayed button text Sets the displayed button text
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):show() -- you could also use :setValue() instead of :setText() - no difference local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):show() -- you could also use :setValue() instead of :setText() - no difference
```` ````
**args:** text<br> **args:** text<br>
**returns:** the object<br> **returns:** the object<br>
# Examples # Examples
Add a onClick event: Add a onClick event:
````lua ````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):show() local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):onClick(function(self,event,button,x,y) local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):onClick(function(self,event,button,x,y)
if(event=="mouse_click")and(button==1)then if(event=="mouse_click")and(button==1)then
NyoUI.debug("Left mousebutton got clicked!") basalt.debug("Left mousebutton got clicked!")
end end
end):show() end):show()
```` ````