From 5c6eef308b7521b43d9b517ad69a52a06c3384fd Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Sun, 24 Apr 2022 16:12:07 +0200 Subject: [PATCH] Updated Button (markdown) --- Button.md | 62 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/Button.md b/Button.md index 6715414..58e747a 100644 --- a/Button.md +++ b/Button.md @@ -1,33 +1,33 @@ Buttons are objects, which execute function by clicking on them - Here is a example of how to create a standard button: - - ````lua - local mainFrame = basalt.createFrame("myFirstFrame"):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 - 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/basalt/wiki/Object): - - ## setText - Sets the displayed button text - ````lua - local mainFrame = basalt.createFrame("myFirstFrame"):show() - local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):show() -- you could also use :setValue() instead of :setText() - no difference - ```` - **args:** text
- **returns:** the object
- - # Examples - Add a onClick event: - ````lua - local mainFrame = basalt.createFrame("myFirstFrame"):show() - local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):onClick(function(self,event,button,x,y) - if(event=="mouse_click")and(button==1)then - basalt.debug("Left mousebutton got clicked!") - end - end):show() - ```` \ No newline at end of file +Here is a example of how to create a standard button: + +````lua +local mainFrame = basalt.createFrame("myFirstFrame"):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 +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/basalt/wiki/Object): + +## setText +Sets the displayed button text +````lua +local mainFrame = basalt.createFrame("myFirstFrame"):show() +local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):show() -- you could also use :setValue() instead of :setText() - no difference +```` +**args:** text
+**returns:** the object
+ +# Examples +Add a onClick event: +````lua +local mainFrame = basalt.createFrame("myFirstFrame"):show() +local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):onClick(function(self,event,button,x,y) +if(event=="mouse_click")and(button==1)then +basalt.debug("Left mousebutton got clicked!") +end +end):show() +```` \ No newline at end of file