Skip to content

Latest commit

 

History

History
301 lines (186 loc) · 4.93 KB

label.rst

File metadata and controls

301 lines (186 loc) · 4.93 KB

Label

A UI element, that displays plain text.

Visual example of Labels

Labels with two styles.

Contents:

Properties

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

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 :ref:`show() <uilib_label_funcs_show>` to enable visibility and :ref:`hide() <uilib_label_funcs_hide>` to disable visibility of the button.


Functions

new()

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


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 :ref:`Label <uilib_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 :ref:`Label <uilib_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 :ref:`Label <uilib_label>` and make it invisible.