Skip to content
Will Thomas edited this page Mar 30, 2014 · 6 revisions

#Overview Label objects can only be created after you have a gui object, by calling the gui's addLabel method. They are the most boring of all elements, capable of doing nothing but sitting there, saying stuff.

Members:

Properties

posX, posY, width, height
The position and dimensions of the label, with position in it's gui's coordinates.
text
The text of the label. What it says, basically.
style
The style table to use on this label. If unset, inherits from it's parent gui.
gui
the gui object this label is contained by.

Methods

label:hide()
Hides the label, preventing it from saying it's thing and and making it sad.
label:show()
Unhides, or shows, the label, allowing it to say it's thing and making it happy again.
label:draw()
Forces the label to be redrawn immediately. Useful if you've been directly manipulating it's style or properties from code and need those changes to update.

Handlers

Handlers are properties that can be set to functions that will be called when certain events happen. Some handlers are common to all components, like onClick, while others are specific to certain types, like onScroll. However, some common handlers are implemented internally, and overriding them can cause undesired results. Only those events listed on these pages for a given element type should be assigned in your programs.

onClick(label,mouseX,mouseY,button)
Called whenever the label is clicked on.
onDoubleClick(label,mouseX,mouseY,button)
Called when you double-click on the label.
onBeginDrag(label,mouseX,mouseY,button)
Called when the player begins to drag after clicking and holding on a label. Always follows an onBeginDrag, many of these can be received, and then a final onDrop event will be received when the user released the button. This function can optionally return a drag proxy, an object which will be held by the gui and send the remaining onDrag and onDrop events,
onDrag(label,mouseX,mouseY)
called when the player drags after clicking on a label. Always follows an onBeginDrag, many of these can be received, and then a final onDrop event will be received.
onDrop(label,mouseX,mouseY,dropOver)
Called when the player releases the mouse button after dragging a label. The dropOver argument is the gui element the mouse was over when the drop occurred.

Styles

Styles specific to labels are applied in gui style sheets using the element "label". At present, Labels have no states, so there are no valid gss :state modifiers that will affect gui styling.

The labels' will inherit the style table used by their containing gui, unless they are explicitly given their own style table. Individual style properties can also be set as values directly on the label object, ex, "label.text-color=0x00ffff" would make the label text bright cyan.

For more general information on styles, see the styles page

###Style Properties

Propery Value Type Description
text-color int1 the color of the label's text
text-background int1 the background color used for the label

1colors are 24-bit, with 8 bits each R, G, and B, and can be given as normal integers, like 0 (which would be black), or hex values, like 0xff0000 (red).

Clone this wiki locally