Properties | Methods | Examples

Classpublic class RadioButton
InheritanceRadioButton Inheritance qnx.fuse.ui.buttons.ToggleButtonBase

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.

You can set a label for each button by using the label property. The following image shows a radio button group listing font names.

A radio button group.

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

View the examples

See also


Public Properties

 PropertyDefined By
  groupname : String
Determines the group for which the RadioButton belongs to.

Protected Properties

 PropertyDefined By
  cssID : String
[override] [read-only] Returns the CSS ID of the component.

Public Methods

 MethodDefined By
Constructs a new RadioButton instance.

Property Detail


cssID:String  [read-only]

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

The default value is RadioButton.


protected function get cssID():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.


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

Constructor Detail


public function RadioButton()

Constructs a new RadioButton instance.


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.

    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import qnx.fuse.ui.buttons.RadioButton;
    import qnx.fuse.ui.buttons.RadioButtonGroup;
    [SWF(frameRate="60", backgroundColor="#FFFFFF")]
    public class RadioButtonSample extends Sprite
        public function RadioButtonSample()
        private function initializeUI():void
            var btnHeight : Number = 80;
            var rb1:RadioButton = new RadioButton();
            rb1.setPosition(50, 100)
            rb1.label = "Meal Option 1";
            rb1.groupname = "rbg1_meals";
            rb1.setActualSize(300, btnHeight);
            addChild( rb1 );
            var rb2:RadioButton = new RadioButton();
            rb2.setPosition( rb1.x, rb1.y + btnHeight );
            rb2.label = "Meal Option 2";
            rb2.groupname = "rbg1_meals";
            rb2.setActualSize(300, btnHeight);
            addChild( rb2 );
            var rb3:RadioButton = new RadioButton();
            rb3.setPosition( rb1.x, rb2.y + btnHeight );
            rb3.label = "Meal Option 3";
            rb3.groupname = "rbg1_meals";
            rb3.setActualSize(300, btnHeight);
            addChild( rb3 );
            var rb4:RadioButton = new RadioButton();
            rb4.setPosition( 400, 100 )
            rb4.label = "Drink Option 1";
            rb4.groupname = "rbg2_drinks";
            rb4.setActualSize(300, btnHeight);
            addChild( rb4 );
            var rb5:RadioButton = new RadioButton();
            rb5.setPosition( rb4.x, rb4.y + btnHeight );
            rb5.label = "Drink Option 2";
            rb5.groupname = "rbg2_drinks";
            rb5.setActualSize(300, btnHeight);
            addChild( rb5 );
            var rb6:RadioButton = new RadioButton();
            rb6.setPosition( rb4.x, rb5.y + btnHeight );
            rb6.label = "Drink Option 3";
            rb6.groupname = "rbg2_drinks";
            rb6.setActualSize(300, btnHeight);
            addChild( rb6 );
            var rbg1:RadioButtonGroup = RadioButtonGroup.getGroup( "rbg1_meals" );
            rbg1.addEventListener( MouseEvent.CLICK, rbg1Change );
            rbg1.setSelectedRadioButton( rb2 );
            var rbg2:RadioButtonGroup = RadioButtonGroup.getGroup( "rbg2_drinks" );
            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");