class Label
package feathers.controls
extends FeathersControl › MeasureSprite › ValidatingSprite
implements IHTMLTextControl, ITextControl
Displays text with an optional background.
The following example creates a label and gives it text:
var label = new Label();
label.text = "Hello World";
this.addChild(label);
1.0.0
.See also:
Static variables
staticfinalread onlyVARIANT_DETAIL:String = "detail"
A variant used to style the label using a smaller text format for details. Variants allow themes to provide an assortment of different appearances for the same type of UI component.
The following example uses this variant:
var label = new Label();
label.variant = Label.VARIANT_DETAIL;
1.0.0
.See also:
staticfinalread onlyVARIANT_HEADING:String = "heading"
A variant used to style the label using a Larger text format for headings. Variants allow themes to provide an assortment of different appearances for the same type of UI component.
The following example uses this variant:
var label = new Label();
label.variant = Label.VARIANT_HEADING;
1.0.0
.See also:
Constructor
Variables
backgroundSkin:DisplayObject
The default background skin to display behind the label's text.
The following example passes a bitmap for the label to use as a background skin:
label.backgroundSkin = new Bitmap(bitmapData);
1.0.0
.See also:
disabledBackgroundSkin:DisplayObject
A background skin to display behind the label's text when the label is disabled.
The following example gives the label a disabled background skin:
label.disabledBackgroundSkin = new Bitmap(bitmapData);
label.enabled = false;
1.0.0
.See also:
disabledTextFormat:AbstractTextFormat
The font styles used to render the label's text when the label is disabled.
In the following example, the label's disabled text formatting is customized:
label.enabled = false;
label.disabledTextFormat = new TextFormat("Helvetica", 20, 0xee0000);
1.0.0
.See also:
embedFonts:Bool
Determines if an embedded font is used or not.
In the following example, the label uses embedded fonts:
label.embedFonts = true;
1.0.0
.See also:
htmlText:String
Text displayed by the label that is parsed as a simple form of HTML.
The following example sets the label's HTML text:
label.htmlText = "<b>Hello</b> <i>World</i>";
1.0.0
.See also:
openfl.text.TextField.htmlText
paddingBottom:Float
The minimum space, in pixels, between the button's bottom edge and the button's content.
In the following example, the button's bottom padding is set to 20 pixels:
button.paddingBottom = 20.0;
1.0.0
.paddingLeft:Float
The minimum space, in pixels, between the button's left edge and the button's content.
In the following example, the button's left padding is set to 20 pixels:
button.paddingLeft = 20.0;
1.0.0
.paddingRight:Float
The minimum space, in pixels, between the button's right edge and the button's content.
In the following example, the button's right padding is set to 20 pixels:
button.paddingRight = 20.0;
1.0.0
.paddingTop:Float
The minimum space, in pixels, between the button's top edge and the button's content.
In the following example, the button's top padding is set to 20 pixels:
button.paddingTop = 20.0;
1.0.0
.selectable:Bool
Indicates if the label's text may be selected or not.
In the following example, the label text is selectable:
label.selectable = true;
1.0.0
.read onlyselectionBeginIndex:Int
The start index of the selection.
If selectable
is false
, returns -1
.
1.0.0
.read onlyselectionEndIndex:Int
The end index of the selection.
If selectable
is false
, returns -1
.
1.0.0
.text:String
The text displayed by the label.
The following example sets the label's text:
label.text = "Good afternoon!";
Note: If the htmlText
property is not null
, the text
property will
be ignored.
1.0.0
.See also:
textFormat:AbstractTextFormat
The font styles used to render the label's text.
In the following example, the label's text formatting is customized:
label.textFormat = new TextFormat("Helvetica", 20, 0xcc0000);
1.0.0
.See also:
verticalAlign:VerticalAlign
How the content is positioned vertically (along the y-axis) within the button.
The following example aligns the button's content to the top:
button.verticalAlign = TOP;
Note: The VerticalAlign.JUSTIFY
constant is not supported by this
component.
See also:
wordWrap:Bool
Determines if the text is displayed on a single line, or if it wraps.
In the following example, the label's text wraps at 150 pixels:
label.width = 150.0;
label.wordWrap = true;
1.0.0
.