Label
A UI element, that displays plain text.
Contents:
Properties
Name |
Type |
Default |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
text
Text, which the label will display.
uilib.Label.text = nil
Type:
string
Default:
nil
x
X component of the position on the screen.
uilib.Label.x = nil
Type:
number
Default:
nil
y
Y component of the position on the screen.
uilib.Label.y = nil
Type:
number
Default:
nil
style
Style of the label.
uilib.Label.style = uilib.Style:new()
Type: uilib.Style
Default: Default Style
visible
Contains information about the label being visible or not.
uilib.Label.visible = true
Type:
boolean
Default:
true
Functions
new()
Function to create a new instance of Label.
function M.Label:new(text, x, y, style)
...
return label
end
Arguments:
Name |
Type |
Default |
Description |
---|---|---|---|
text |
|
|
Text, which the label will display. |
x |
|
|
X component of position of the label. |
y |
|
|
Y component of position of the label. |
style |
Style of the label. |
Note
Labels can only use the default state for styling.
Returns:
Type |
Description |
---|---|
Instance of Label with specified properties. |
Example:
local uilib = require("uilib")
local label = uilib.Label("I am a Label!", 4, 5, uilib.Style:new(colors.red, colors.gray))
This would create an instance of a Label with the text I am a Label!
with colors.red
text on colors.gray
background at position (4, 5)
.
draw()
Function to draw the label.
function M.Label:draw()
...
end
Arguments: nil
Returns: nil
Example:
local uilib = require("uilib")
local label = uilib.Label("I am a Label!", 4, 5, uilib.Style:new(colors.red, colors.gray))
label:draw()
This would create an instance of Label and draw it to the screen.
show()
Function to make the label visible.
function uilib.Label:show()
...
end
Arguments: nil
Returns: nil
Example:
local uilib = require("uilib")
local label = uilib.Label("I am a Label!", 4, 5, uilib.Style:new(colors.red, colors.gray))
label:show()
This would create an instance of Label and make it visible.
hide()
Function to make the label invisible.
function uilib.Label:hide()
...
end
Arguments: nil
Returns: nil
Example:
local uilib = require("uilib")
local label = uilib.Label("I am a Label!", 4, 5, uilib.Style:new(colors.red, colors.gray))
label:hide()
This would create an instance of Label and make it invisible.