qnx.fuse.ui.buttons.LabelButton

LabelButton

Properties | Methods | Events | Examples


Packageqnx.fuse.ui.buttons
Classpublic class LabelButton
InheritanceLabelButton Inheritance Button Inheritance SkinnableComponent Inheritance UIComponent Inheritance flash.display.MovieClip
Subclasses BackButton, ExpandableControlLabelButton, IconLabelButton, ToastButton

The LabelButton class allows you to add a label to a standard Button.

A label button.



Class information:
BlackBerry 10 Version:   10.0.0
Found in:  qnxui.swc

View the examples

See also

Button
IconButton



Public Properties

 PropertyDefined By
 InheritedcontextActions : Vector.<ActionSet>
Gets or Sets a Vector of ActionSet objects.
UIComponent
 InheritedcontextMultiSelectText : String
Gets or Sets a String to be displayed when showing the Multi Select Context Menu.
UIComponent
 InheritedcurrentTheme : String
[read-only] Returns the current theme this component is styled with.
UIComponent
 InheritedexplicitHeight : Number
[read-only] Returns the explicit height (actual height, in pixels) of the UI component.
UIComponent
 InheritedexplicitWidth : Number
[read-only] Returns the explicit width (actual width, in pixels) of the UI component.
UIComponent
 Inheritedid : String
The id is a name for the component that can be used in CSS using the # selector.
UIComponent
 InheritedincludeInLayout : Boolean
Specifies whether or not the component should be included in its parent container's layout.
UIComponent
  label : String
Gets or sets the label for the button.
LabelButton
 InheritedlayoutData : Object
Gets or sets the layoutData.
UIComponent
 Inheritedlocale : String
Gets or sets the current locale of the component.
UIComponent
 InheritedminHeight : Number
Gets or sets the minimum preferred height of the control.
UIComponent
 InheritedminWidth : Number
Gets or sets the minimum preferred width of the control.
UIComponent
  paddingBottom : uint
Sets the number of extra pixels that are added to the bottom of the label, between the text and the border of the button.
LabelButton
  paddingLeft : uint
Sets the number of extra pixels that are added to the left of the label, between the border of the button and the text.
LabelButton
  paddingRight : uint
Sets the number of extra pixels that are added to the right of the label, between the text and the border of the button.
LabelButton
  paddingTop : uint
Sets the number of extra pixels that are added to the top of the label, between the border of the button and the text.
LabelButton
 Inheritedselected : Boolean
Setting the selected property changes the visual state of the Button to selected.
Button
 Inheritedstate : String
Gets or sets the state of the component.
SkinnableComponent
 InheritedstyleChildren : Boolean
Allows you to style the children of this component with CSS.
UIComponent
 Inheritedtoggle : Boolean
The toggle property allows the button to switch between its selected and released states each time it's tapped.
Button
  truncationMode : String
Gets or sets the truncationMode of the button, which defines how the label in the button will be treated when the it is too large to appear within the dimensions of the button.
LabelButton

Protected Properties

 PropertyDefined By
 InheritedaccessibilityImplimentationClass : Class
UIComponent
  cssID : String
[override] [read-only] Returns the CSS ID of the component.
LabelButton
 InheritedexplicitLocale : Boolean
Set to true when the locale property has been set externally.
UIComponent
 InheritedinternalID : String
The Component's Id used for styling.
UIComponent
 InheritedlongPressEnabled : Boolean
Specifies whether the UIComponent can detect a long press.
UIComponent

Public Methods

 MethodDefined By
  
Creates a new LabelButton instance.
LabelButton
 Inherited
Cancels a long press from occuring on the component.
UIComponent
 Inherited
childChanged(resizedChild:DisplayObject = null):Boolean
Notifies the UIComponent that one or more of its children has changed in a manner that may affect this object's layout.
UIComponent
 Inherited
configureStyles(styles:Array):void
[override] The SkinnableComponent version styles the component with the base style first, and then styles it with the current state's style.
SkinnableComponent
 Inherited
destroy():void
Call this method when you want to have your object collected by the garbage collector.
UIComponent
 Inherited
Returns the CSS selector for the object, composing it from its position in the display hierarchy and an optional ID selector.
UIComponent
 Inherited
Returns the size options for the given control.
UIComponent
  
Returns the TextFormat object for a specified state.
LabelButton
 Inherited
Calling this method results in a call to the components validateDisplayList() method before the display list is rendered.
UIComponent
 Inherited
Calling this method results in a call to the components validateProperties() method before the display list is rendered.
UIComponent
 Inherited
measure(availableWidth:Number, availableHeight:Number):LayoutMeasurement
This method calls doMeasure() in order to calculate the preferred size of the control.
UIComponent
 Inherited
setActualSize(w:Number, h:Number):void
Sets the width and height of the object without setting the explicitWidth and explicitHeight.
UIComponent
 Inherited
setLayoutBounds(bounds:Rectangle):void
Sets the receiver's size and location to the rectangular area specified by the arguments.
UIComponent
 Inherited
setPosition(x:Number, y:Number):void
Sets the x and y position of the component.
UIComponent
 Inherited
setSkin(newSkin:Object):void
Set the skin object on the component for it to render.
SkinnableComponent
  
setTextFormatForState(format:TextFormat, stateToModify:String):void
Sets the TextFormat object for the label for a given state.
LabelButton
 Inherited
updateDefaultLocale(updateChildren:Boolean = true):void
Updates the locale property to be the same as the locale of the device.
UIComponent
  
[override] Updates the internal Label component to reflect the latest font settings.
LabelButton
 Inherited
Validates the display list of the component by calling the updateDisplayList().
UIComponent
 Inherited
Validates the component immediately by calling validateProperties(), validateSizes(), and validateDisplayList() if necessary.
UIComponent
 Inherited
Validates the properties of the component by calling the commitProperties() method.
UIComponent

Protected Methods

 MethodDefined By
 Inherited
allowShowContextMenu(target:IEventDispatcher):Boolean
When the user presses on the component this method is called with the object that dispatched the event.
UIComponent
 Inherited
Process properties of the component.
UIComponent
 Inherited
Process the state of the component.
UIComponent
 Inherited
Style the component after the style has changed.
UIComponent
 Inherited
doMeasure(availableWidth:Number, availableHeight:Number):LayoutMeasurement
Performs a measurement on the control, and returns a LayoutMeasurement instance containing the available width and height within the layout.
UIComponent
 Inherited
excemptFromCSSStyling(target:*, property:String = null):void
Exempts a property on an object from being styled by CSS.
UIComponent
 Inherited
flushCache():void
Invoked as part of parentLayoutChanged.
UIComponent
 Inherited
getStyleApplier():Function
A style applier is a method that gets called every time a property from the stylesheet should be applied to the component.
UIComponent
 Inherited
getStyleForState(state:String):IStyleable
A utility method to get the styling information for a given state.
SkinnableComponent
 Inherited
onAdded():void
Called when the instance is added to the stage.
UIComponent
 Inherited
Is called when a user is no longer long pressing on the component.
UIComponent
 Inherited
Is called when a user long presses on the component.
UIComponent
 Inherited
onRemoved():void
Called when the instance is removed from the stage.
UIComponent
 Inherited
Invalidates the parent's size and display list if includeInLayout property is set to true.
UIComponent
 Inherited
Calling this function will refresh the ContextMenu with whatever actions were set by contextActions.
UIComponent
 Inherited
Shows the context menu if there are contextActions associated with the control.
UIComponent
 Inherited
styleState():void
Style the component after state has changed.
UIComponent
 Inherited
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
Sets the size and position of the children of the component.
UIComponent
 Inherited
updateSkin(unscaledWidth:Number, unscaledHeight:Number):void
Updates the skin's dimensions.
SkinnableComponent

Events

 Event Summary Defined By
 InheritedDispatched when an action in the Context Menu is selected.UIComponent
 InheritedDispatched when the Context Menu has closed to the DISMISSED state.UIComponent
 InheritedDispatched when the ContextMenu is closing to the DISMISSED state.UIComponent
 InheritedDispatched when the Context Menu has opened to the PEEK or EXPANDED state.UIComponent
 InheritedDispatched when the ContextMenu is opening from the DISMISSED state.UIComponent
 InheritedDispatched when the CrossCut multiselect has been canceled.UIComponent

Property Detail

cssID


cssID:String  [read-only]
[override]

Returns the CSS ID of the component. The CSS ID is used for identifying the type of component in CSS.

The default value is LabelButton.


Implementation

protected function get cssID():String

label


label:String

Gets or sets the label for the button.


Implementation

public function get label():String
public function set label(value:String):void

paddingBottom


paddingBottom:uint

Sets the number of extra pixels that are added to the bottom of the label, between the text and the border of the button.

This affects the preferred size of the button and may be overridden by the layout.


Implementation

public function get paddingBottom():uint
public function set paddingBottom(value:uint):void

paddingLeft


paddingLeft:uint

Sets the number of extra pixels that are added to the left of the label, between the border of the button and the text.

This affects the preferred size of the button and may be overridden by the layout.


Implementation

public function get paddingLeft():uint
public function set paddingLeft(value:uint):void

paddingRight


paddingRight:uint

Sets the number of extra pixels that are added to the right of the label, between the text and the border of the button.

This affects the preferred size of the button and may be overridden by the layout.


Implementation

public function get paddingRight():uint
public function set paddingRight(value:uint):void

paddingTop


paddingTop:uint

Sets the number of extra pixels that are added to the top of the label, between the border of the button and the text. This affects the preferred size of the button and may be overridden by the layout.


Implementation

public function get paddingTop():uint
public function set paddingTop(value:uint):void

truncationMode


truncationMode:String

Gets or sets the truncationMode of the button, which defines how the label in the button will be treated when the it is too large to appear within the dimensions of the button. The label can be clipped, or truncated.

Valid values can be found in the TextTruncationMode class.

The image below shows an example of the truncationMode being set to TextTruncationMode.TRUNCATE_TAIL with overflowing text:

A radio button group.

The image below shows an example of the truncationMode being set to TextTruncationMode.CLIP with overflowing text:

A radio button group.

The default value is qnx.fuse.ui.text.TextTruncationMode.TRUNCATE_TAIL.


Implementation

public function get truncationMode():String
public function set truncationMode(value:String):void

See also

qnx.fuse.ui.text.TextTruncationModeTextTruncationMode
TextTruncationMode.TRUNCATE_TAIL

Constructor Detail

LabelButton()


public function LabelButton()

Creates a new LabelButton instance.

Method Detail

getTextFormatForState()


public function getTextFormatForState(state:String):TextFormat

Returns the TextFormat object for a specified state.

Parameters

state:String — The state for the TextFormat object to return. Valid states are:
  • SkinStates.UP
  • SkinStates.DOWN
  • SkinStates.SELECTED
  • SkinStates.DISABLED
  • SkinStates.DISABLED_SELECTED
  • SkinStates.DOWN_SELECTED

Returns

TextFormat — The TextFormat object for the specified state.

See also

setTextFormatForState()
SkinStates

setTextFormatForState()


public function setTextFormatForState(format:TextFormat, stateToModify:String):void

Sets the TextFormat object for the label for a given state. Valid states are:

  • SkinStates.UP
  • SkinStates.DOWN
  • SkinStates.SELECTED
  • SkinStates.DISABLED
  • SkinStates.DISABLED_SELECTED
  • SkinStates.DOWN_SELECTED
If the values of the supplied TextFormat are equal to the TextFormat that currently exists for the style, no change occurs and the LabelButton is not redrawn. Setting a TextFormat through this method will replace all styles that are defined in the ThemeGlobals CSS, so use this only if you want to replace all the default styles for the state.

Parameters

format:TextFormat — The TextFormat to set.
stateToModify:String — The state for which to change the TextFormat.

See also

SkinStates
getTextFormatForState()

updateFontSettings()


override public function updateFontSettings():void

Updates the internal Label component to reflect the latest font settings. This will potentially resize the component.

The updateFontsettings method is not called on children of the LabelButton class automatically. If you write a component that extends LabelButton and contains text based controls, you must extend this method and call updateFontSettings on these children to see the new font settings reflected in them.

It is only necessary to call this method after the application has received a Event.CHANGE event from the FontSettings class.

See also

qnx.system.FontSettings

Examples

The following code listing describes how to modify the appearance of your button text depending on the button's state. You can set separate text format objects for each button state. This enables your button text to change color, position, size, or font face whenever a user presses the button, when it is disabled, etc.

In this short example two text format objects are created and associated with button states. The text format object formatDown is created and associated with the DOWN state using the setTextFormatForState method. The formatDown object specifies the button label text as white.

package
{
    import flash.display.Sprite;
    import flash.text.TextFormatAlign;    
    import qnx.fuse.ui.buttons.LabelButton;
    import qnx.fuse.ui.skins.SkinStates;
    import qnx.fuse.ui.text.TextFormat;
    
    public class SkinSample extends Sprite
    {
        public function SkinSample()
        {
            // create a text format for up, disabled, selected, etc. 
            // black label text
            var format:TextFormat = new TextFormat();
            format.font = "Myriad Pro";
            format.size = 21;
            format.color = 0x000000;
            format.align = Align.CENTER;
            
            // create a text format for the down state 
            // white label text
            var formatDown:TextFormat = new TextFormat();
            formatDown.font = "Slate Pro";
            format.size = 16;
            formatDown.color = 0xFFFFFF;
            formatDown.align = Align.CENTER;
            
            var _button:LabelButton = new LabelButton();
            
            // set the formats for each state you want to address 
            _button.setTextFormatForState(format, SkinStates.UP); 
            _button.setTextFormatForState(formatDown, SkinStates.DOWN);
            _button.setTextFormatForState(format, SkinStates.DISABLED);
            _button.setTextFormatForState(format, SkinStates.SELECTED);
            _button.setTextFormatForState(format, SkinStates.DISABLED_SELECTED);
            
            _button.label = "OK";
            _button.x = _button.y = 175;
            
            addChild(_button);
        }
    }
}
     




comments powered by Disqus