Label

A UI element, that displays plain text.

Visual example of Labels

Labels with two styles.

Contents:

Properties

Name

Type

Default

text

string

nil

x

number

nil

y

number

nil

style

uilib.Style

Default Style

visible

boolean

true

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()

visible

Contains information about the label being visible or not.

uilib.Label.visible = true
  • Type: boolean

  • Default: true

Note

Please use show() to enable visibility and hide() to disable visibility of the button.


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

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

uilib.Style

Default Style

Style of the label.

Note

Labels can only use the default state for styling.

Returns:

Type

Description

uilib.Label

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.