qnx.fuse.ui.buttons.RadioButton

RadioButton

Properties | Methods | Examples


Packageqnx.fuse.ui.buttons
Classpublic class RadioButton
InheritanceRadioButton Inheritance LabelButton Inheritance Button Inheritance SkinnableComponent Inheritance UIComponent Inheritance flash.display.MovieClip

The RadioButton component lets you force a user to make a single selection from a set of choices. This component must be used in a group of at least two RadioButton instances, and each RadioButton instance must be a member of a RadioButtonGroup. Each RadioButtonGroup must have a unique name. You can only select a single radio button at any given time. When you select a radio button, you deselect the currently selected radio button in the group.

By default, the RadioButton class uses the same skin as the LabelButton. You can set a label for each button by using the label property. The following image shows two radio button groups that use the default button style:

A radio button group.

You can use the setSkin() method to apply one of the included round radio button skins to a RadioButton instance. The RadioButtonSkinWhite and RadioButtonSkinBlack skins give each radio button the common, round appearance. The following image shows a set of RadioButton instances that use the RadioButtonSkinWhite skin:

A radio button group using the RadioButtonWhiteSkin.

The label property is not compatible with the RadioButtonSkinWhite and RadioButtonSkinBlack skins.



Class information:
PlayBook Tablet OS Version:   1.0.6

View the examples

See also

Button
RadioButtonGroup



Public Properties

 PropertyDefined By
 InheritedembedFonts : Boolean
Gets or sets the embedFonts property of the internal TextField of the LabelButton.
LabelButton
 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
  groupname : String
Determines the group for which the RadioButton belongs to.
RadioButton
 InheritedincludeInLayout : Boolean
Specifies whether or not the component should be included in its parent container's layout.
UIComponent
 Inheritedlabel : String
Gets or sets the label for the button.
LabelButton
 InheritedlayoutData : Object
Returns the layout data for the object.
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
 InheritedpaddingBottom : uint
Sets the number of extra pixels that are added on the bottom, between the text and the border of the button.
LabelButton
 InheritedpaddingLeft : uint
Sets the number of extra pixels that are added on the left, between the border of the button and the text.
LabelButton
 InheritedpaddingRight : uint
Sets the number of extra pixels that are added on the right, between the text and the border of the button.
LabelButton
 InheritedpaddingTop : uint
Sets the number of extra pixels that are added on the top, between the border of the button and the text.
LabelButton
 Inheritedselected : Boolean
Gets or sets the selected property of the button.
Button
 Inheritedstate : String
Gets or sets the state of the component.
SkinnableComponent
 Inheritedtoggle : Boolean
Gets or sets the toggle property of the button.
Button
 InheritedtruncationMode : String
Gets or sets the truncationMode of the button.
LabelButton

Public Methods

 MethodDefined By
  
Constructs a new RadioButton instance.
RadioButton
 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
destroy():void
Call this method when you want to have your object collected by the garbage collector.
UIComponent
 Inherited
Returns the size options for the given control.
UIComponent
 Inherited
getTextFormatForState(state:String):TextFormat
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
 Inherited
setTextFormatForState(format:TextFormat, stateToModify:String):void
Sets the TextFormat object for the label for a given state.
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
Process properties of the component.
UIComponent
 Inherited
Process the state of the component.
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
flushCache():void
Invoked as part of parentLayoutChanged.
UIComponent
 Inherited
onAdded():void
Called when the instance is added to the stage.
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
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.
SkinnableComponent

Property Detail

groupname


groupname:String

Determines the group for which the RadioButton belongs to. You must specify the name of a valid RadioButtonGroup in order to distinguish a related set of RadioButton instances. If no group with the specified unique name exists, a new RadioButtonGroup instance will be created and the button will be added to the new group.

A RadioButton can only belong to a single group at any given time.

The default value is QNXRadioButtonGroup.


Implementation

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

Constructor Detail

RadioButton()


public function RadioButton()

Constructs a new RadioButton instance.

Examples

In the following example, six RadioButton instances and two RadioButtonGroup instances are created. The RadioButtonGroup instances are given unique names by passing in unique group names to the getGroup() method.

package
{
    import flash.display.Sprite;
    import flash.events.MouseEvent;

    import qnx.fuse.ui.buttons.RadioButton;
    import qnx.fuse.ui.buttons.RadioButtonGroup;

    [SWF(height="600", width="1024", frameRate="30",
    backgroundColor="#FFFFFF")]
    public class RadioButtonSample extends Sprite
    {

        public function RadioButtonSample()
        {
            initializeUI();

        }

        private function initializeUI():void
        {
            var rb1:RadioButton = new RadioButton();
            rb1.setPosition(100, 100)
            rb1.label = "Meal option 1";
            rb1.groupname = "rbg1_meals13";
            addChild( rb1 );

            var rb2:RadioButton = new RadioButton();
            rb2.setPosition( rb1.x, rb1.y + 40 );
            rb2.label = "Meal option 2";
            rb2.groupname = "rbg1_meals13";
            addChild( rb2 );


            var rb3:RadioButton = new RadioButton();
            rb3.setPosition( rb1.x, rb2.y + 40 );
            rb3.label = "Meal option 3";
            rb3.groupname = "rbg1_meals13";
            addChild( rb3 );


            var rb4:RadioButton = new RadioButton();
            rb4.setPosition( 300, 100 )
            rb4.label = "Meal option 4";
            rb4.groupname = "rbg1_meals46";
            addChild( rb4 );

            var rb5:RadioButton = new RadioButton();
            rb5.setPosition( rb4.x, rb4.y + 40 );
            rb5.label = "Meal option 5";
            rb5.groupname = "rbg1_meals46";
            addChild( rb5 );


            var rb6:RadioButton = new RadioButton();
            rb6.setPosition( rb4.x, rb5.y + 40 );
            rb6.label = "Meal option 6";
            rb6.groupname = "rbg1_meals46";
            addChild( rb6 );

            var rbg1:RadioButtonGroup = RadioButtonGroup.getGroup( "rbg1_meals13" );
            rbg1.addEventListener( MouseEvent.CLICK, rbg1Change );
            rbg1.setSelectedRadioButton( rb2 );

            var rbg2:RadioButtonGroup = RadioButtonGroup.getGroup( "rbg1_meals46" );
            rbg2.addEventListener( MouseEvent.CLICK, rbg2Change );
            rbg2.setSelectedRadioButton( rb5 );
        }


        private function rbg1Change( event:MouseEvent ):void{
            trace("rbg1 change event");

        }

        private function rbg2Change( event:MouseEvent) :void{
            trace("rbg2 change event");

        }

    }
}


     

In the following listing, a set of RadioButton instances are created that use the RadioButtonSkinWhite class. The RadioButton instances in this example appear round. When the user clicks a radio button, the button is selected and becomes highlighted with a black dot.

package
{
    import flash.display.Sprite;
    import flash.events.MouseEvent;

    import qnx.fuse.ui.buttons.RadioButton;
    import qnx.fuse.ui.buttons.RadioButtonGroup;
    import qnx.fuse.ui.skins.buttons.RadioButtonSkinWhite;
    import qnx.fuse.ui.skins.buttons.RadioButtonSkinBlack;

    [SWF(height="600", width="1024", frameRate="30",
    backgroundColor="#FFFFFF")]
    public class RadioButtonRoundSample extends Sprite
    {

        public function RadioButtonRoundSample()
        {
            initializeUI();

        }

        private function initializeUI():void
        {
            var rb1:RadioButton = new RadioButton();
            rb1.setPosition(100, 100)
            rb1.setSkin(RadioButtonSkinWhite);
            rb1.groupname = "rbg1_gp";
            addChild( rb1 );

            var rb2:RadioButton = new RadioButton();
            rb2.setPosition( rb1.x, rb1.y + 40 );
            rb2.setSkin(RadioButtonSkinWhite);
            rb2.groupname = "rbg1_gp";
            addChild( rb2 );


            var rb3:RadioButton = new RadioButton();
            rb3.setPosition( rb1.x, rb2.y + 40 );
            rb3.setSkin(RadioButtonSkinWhite);
            rb3.groupname = "rbg1_gp";
            addChild( rb3 );


            var rbg1:RadioButtonGroup;
            rbg1 = RadioButtonGroup.getGroup( "rbg1_gp" );
            rbg1.addButton( rb1 );
            rbg1.addButton( rb2 );
            rbg1.addButton( rb3 );
            rbg1.addEventListener( MouseEvent.CLICK, rbgChange );
            rbg1.setSelectedRadioButton( rb2 );


        }


        private function rbgChange( event:MouseEvent ):void{
            trace("rbg1 change event");

        }



    }
}