Link Search Menu Expand Document

Label

A label, used to display text in Alloverse

Constructor

 --Creates a Label, at origo, that is 1m wide, 20cm tall and 1cm deep
 local l = Label{bounds=Bounds(0, 0, 0, 1, 0.2, 0.01)}

 --For convenience, you may also set some or all of the Label's properties within the constructor, i.e.:
 local l = Label{bounds=Bounds(0, 0, 0, 1.0, 0.1, 0.001), color={1.0,0.2,0.4,1}, text="Hello!", halign="left"}

Note: The font size of the text is, by default, derived from the height of the Label.

Arguments

Name Type Description
o table A table including at least a Bounds component. It may also include a number of other optional properties: text, wrap, halign, color and fitToWidth.

Returns

Nothing


Methods

label:setText (text)

Sets the Label’s text

Arguments

Name Type Description
text string The text the Label should display

Returns

Nothing


label:setWrap (wrap)

Sets the Label’s horizontal wrap attribute

Arguments

Name Type Description
wrap boolean Whether the Label should line break when reaching the Label’s bounds’ (true) or be allowed to overflow outside the component (false)

Returns

Nothing


label:setHalign (halign)

Sets the Label’s horizontal align attribute

Arguments

Name Type Description
halign “center”,”top”,”bottom” The alignment of the text within the Labels’ bounds

Returns

Nothing


label:setColor (color)

Sets the Label’s text color

Arguments

Name Type Description
color {r,g,b,a} The r, g, b and a values of the text color, each defined between 0 and 1.

Returns

Nothing


label:setFitToWidth (fitToWidth)

Sets the Label’s fitToWidth attribute Note: If true, the wrap attribute is made irrelevant.

Arguments

Name Type Description
fitToWidth boolean Wether the Label’s font size should dynamically shink in order to always fit in the label’s width.

Returns

Nothing