Licensed to the Apache Software Foundation (ASF) under one or more

contributor license agreements. See the NOTICE file distributed with

this work for additional information regarding copyright ownership.

The ASF licenses this file to You under the Apache License, Version 2.0

(the “License”); you may not use this file except in compliance with

the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an “AS IS” BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

layout: docpage title: Jewel Label description: The Jewel Label permalink: /component-sets/jewel/label

< Jewel Components list

Jewel Label

Reference

Available since version 0.9.4.

ClassExtends
org.apache.royale.jewel.Label{:target=‘_blank’}org.apache.royale.core.supportClasses.StyledImageBase{:target=‘_blank’}

Note: This component is currently only available for JavaScript.

Overview

The Jewel Label implements the Jewel control for single and multi line text labels. It dispatches a click event when the user clicks over it.

Example of use

In MXML declare a Label like this:

<j:Label/>

In ActionScript we can do the same in the following way:

var label:Label = new Label();
parent.addElement(label);

where parent is the container where the control will be added.

Here is an example of the default label:

code here{:target=‘_blank’}

Relevant Properties and Methods

Check the Reference of org.apache.royale.jewel.Label{:target=‘_blank’} for a more detailed list of properties and methods.

Properties

PROPERTYTypeDescription
textStringThe text inside the label.
htmlStringThe html text inside the label.
multilineBooleanfalse for single line. true for multiline.

Methods

None.

Relevant Events

The Label has a click event of type org.apache.royale.events.Event{:target=‘_blank’}. This event is dispatched when the user clicks the control and triggers some action coded in a callback function. Programmatic changes will not trigger this event.

You can attach callback listeners to the click event in MXML as follows:

<j:Label click="clickHandler(event)"/>

the click event will use the clickHandler callback function you provide in ActionScript:

<fx:Script>
    <![CDATA[      
        private function clickHandler(event:Event):void {
            trace("You clicked the label!");
        }
    ]]>
</fx:Script>

When the user clicks the label, the message “You clicked the label!” appears in the console log.

In ActionScript we can add an event handler this way:

var label:Label = new Label();
label.addEventListener('click', clickHandler);
parent.addElement(label);

Relevant Beads

Unlike other components in Royale, the Jewel Label does not have beads for View pr Controller in the JavaScript platform, but has Model.

Bead TypeImplementationDescription
IBeadModel{:target=‘_blank’}org.apache.royale.jewel.beads.models.TextModel{:target=‘_blank’}The data model for the Label.

Jewel does not have beads specially crafted for this control, but it can use other common Jewel control beads (shared with other controls) to provide more functionality.

Label Beads

None

Common Beads

Bead TypeImplementationDescription
Disabled{:target=‘_blank’}org.apache.royale.core.IBead{:target=‘_blank’}This bead lets you disable and enable a Jewel control.
SizeControl{:target=‘_blank’}org.apache.royale.core.IBead{:target=‘_blank’}Add this bead to give the Jewel control a custom size.
ToolTip{:target=‘_blank’}org.apache.royale.core.IBead{:target=‘_blank’}Add this bead to enable floating a text string over the control when the user hovers the mouse cursor over it.

More examples