Update Label.md
This commit is contained in:
@@ -1,35 +1,54 @@
|
|||||||
With the Label object you are able to add some text.
|
A label is for adding simple 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.
|
||||||
|
|
||||||
|
The fontsize feature is calculated by bigfonts, a library made by Wojbie (http://www.computercraft.info/forums2/index.php?/topic/25367-bigfont-api-write-bigger-letters-v10/)
|
||||||
|
|
||||||
Here are all possible functions available for labels.<br>
|
Here are all possible functions available for labels.<br>
|
||||||
Remember Label inherits from [Object](objects/Object.md)
|
Remember Label inherits from [Object](objects/Object.md)
|
||||||
|
|
||||||
## setText
|
## setText
|
||||||
sets the text which gets displayed.
|
Sets the text which gets displayed.
|
||||||
|
|
||||||
|
#### Parameters:
|
||||||
|
1. `string` The text which should be displayed
|
||||||
|
|
||||||
|
#### Returns:
|
||||||
|
1. `object` The object in use
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
* Creates a default label with text "Some random text".
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
local aInput = mainFrame:addLabel("myFirstLabel"):setText("Hello lovely basalt community!"):show()
|
local aLabel = mainFrame:addLabel("myFirstLabel"):setText("Some random text"):show()
|
||||||
```
|
```
|
||||||
#### Parameters: string text<br>
|
|
||||||
#### Returns: self<br>
|
|
||||||
|
|
||||||
## setFontSize
|
## setFontSize
|
||||||
sets the font size of that text.
|
Sets the font size, calculated by bigfonts. Default size is 1.
|
||||||
The font size is handled by bigfonts, if you're curious what bigfonts is, check out this page: http://www.computercraft.info/forums2/index.php?/topic/25367-bigfont-api-write-bigger-letters-v10/
|
|
||||||
|
#### Parameters:
|
||||||
|
1. `number` The size (1, 2, 3, 4)
|
||||||
|
|
||||||
|
#### Returns:
|
||||||
|
1. `object` The object in use
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
* Creates a default label, sets the text to "Basalt!" and its font size to 2.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
local aInput = mainFrame:addLabel("myFirstLabel"):setText("Hello"):setFontSize(2):show()
|
local aLabel = mainFrame:addLabel("myFirstLabel"):setText("Basalt!"):setFontSize(2):show()
|
||||||
```
|
```
|
||||||
#### Parameters: number size (1 = default, 2 = big, 3 = bigger, 4 = huge)<br>
|
|
||||||
#### Returns: self<br>
|
|
||||||
|
|
||||||
## getFontSize
|
## getFontSize
|
||||||
returns the fontsize
|
Returns the current font size
|
||||||
|
|
||||||
|
#### Returns:
|
||||||
|
1. `number` font size
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
* Creates a default label, sets the text to "Basalt!" and its font size to 2. Also prints the current fontsize.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
local aInput = mainFrame:addLabel("myFirstLabel"):setText("Hello"):setFontSize(2):show()
|
local aLabel = mainFrame:addLabel("myFirstLabel"):setText("Basalt!"):setFontSize(2):show()
|
||||||
basalt.debug(aInput:getFontSize()) -- returns 2
|
basalt.debug(aLabel:getFontSize())
|
||||||
```
|
```
|
||||||
#### Parameters: <br>
|
|
||||||
#### Returns: number<br>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user