A UI element, that displays plain text.
Contents:
Name | Type | Default |
---|---|---|
:ref:`text <uilib_label_props_text>` | string |
nil |
:ref:`x <uilib_label_props_x>` | number |
nil |
:ref:`y <uilib_label_props_y>` | number |
nil |
:ref:`style <uilib_label_props_style>` | :ref:`uilib.Style <uilib_style>` | :ref:`Default Style <uilib_style_funcs_new>` |
:ref:`visible <uilib_label_props_visible>` | boolean |
true |
Text, which the label will display.
uilib.Label.text = nil
- Type:
string
- Default:
nil
X component of the position on the screen.
uilib.Label.x = nil
- Type:
number
- Default:
nil
Y component of the position on the screen.
uilib.Label.y = nil
- Type:
number
- Default:
nil
Style of the label.
uilib.Label.style = uilib.Style:new()
Contains information about the label being visible or not.
uilib.Label.visible = true
- Type:
boolean
- Default:
true
Note
Please use :ref:`show() <uilib_label_funcs_show>` to enable visibility and :ref:`hide() <uilib_label_funcs_hide>` to disable visibility of the button.
- :ref:`new() <uilib_label_funcs_new>`
- :ref:`draw() <uilib_label_funcs_draw>`
- :ref:`show() <uilib_label_funcs_show>`
- :ref:`hide() <uilib_label_funcs_hide>`
Function to create a new instance of :ref:`Label <uilib_label>`.
function M.Label:new(text, x, y, style)
...
return label
end
Arguments:
Name | Type | Default | Description |
---|---|---|---|
text | string |
nil |
Text, which the label will display. |
x | number |
nil |
X component of position of the label. |
y | number |
nil |
Y component of position of the label. |
style | :ref:`uilib.Style <uilib_style>` | :ref:`Default Style <uilib_style_funcs_new>` | Style of the label. |
Note
Labels can only use the :ref:`default state <uilib_style_states>` for styling.
Returns:
Type | Description |
---|---|
:ref:`uilib.Label <uilib_label>` | Instance of :ref:`Label <uilib_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 :ref:`Label <uilib_label>` with the text I am a Label!
with colors.red
text on colors.gray
background at position (4, 5)
.
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 :ref:`Label <uilib_label>` and draw it to the screen.
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 :ref:`Label <uilib_label>` and make it visible.
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 :ref:`Label <uilib_label>` and make it invisible.