This is an automated email from the ASF dual-hosted git repository.

carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new b49bd41  jewel refactor CheckBox and RadioButton to use 
SelectableButtonBase, clean code and update docs to use on Royale-docs
b49bd41 is described below

commit b49bd41f68ab17dfe792a051135cfbdcbe194ec9
Author: Carlos Rovira <[email protected]>
AuthorDate: Wed Aug 28 21:22:55 2019 +0200

    jewel refactor CheckBox and RadioButton to use SelectableButtonBase, clean 
code and update docs to use on Royale-docs
---
 .../projects/Jewel/src/main/royale/JewelClasses.as |   1 +
 .../royale/org/apache/royale/jewel/CheckBox.as     | 310 ++++--------
 .../royale/org/apache/royale/jewel/RadioButton.as  | 523 ++++++++-------------
 .../button/SelectableButtonBase.as}                | 201 ++------
 4 files changed, 326 insertions(+), 709 deletions(-)

diff --git a/frameworks/projects/Jewel/src/main/royale/JewelClasses.as 
b/frameworks/projects/Jewel/src/main/royale/JewelClasses.as
index 5e81927..a731a42 100644
--- a/frameworks/projects/Jewel/src/main/royale/JewelClasses.as
+++ b/frameworks/projects/Jewel/src/main/royale/JewelClasses.as
@@ -110,6 +110,7 @@ package
         import org.apache.royale.jewel.supportClasses.list.DataGroup; 
DataGroup;
         import 
org.apache.royale.jewel.supportClasses.formitem.FormItemLayoutProxy; 
FormItemLayoutProxy;
         import 
org.apache.royale.jewel.supportClasses.wizard.WizardLayoutProxy; 
WizardLayoutProxy;
+        import 
org.apache.royale.jewel.supportClasses.button.SelectableButtonBase; 
SelectableButtonBase;
 
         import 
org.apache.royale.jewel.supportClasses.util.positionInsideBoundingClientRect; 
positionInsideBoundingClientRect;
 
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/CheckBox.as 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/CheckBox.as
index b195417..499dbd6 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/CheckBox.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/CheckBox.as
@@ -20,53 +20,39 @@ package org.apache.royale.jewel
 {
     COMPILE::SWF
     {
-    import org.apache.royale.core.UIButtonBase;
-    import org.apache.royale.events.MouseEvent;
     import org.apache.royale.core.IToggleButtonModel;
-    import org.apache.royale.utils.ClassSelectorList;
-    import org.apache.royale.utils.IClassSelectorListSupport;
+    import org.apache.royale.events.MouseEvent;
     }
 
     COMPILE::JS
     {
-    import org.apache.royale.core.StyledUIBase;
     import org.apache.royale.core.WrappedHTMLElement;
+    import org.apache.royale.events.Event;
     import org.apache.royale.html.util.addElementToWrapper;
     }
 
-    import org.apache.royale.core.ISelectable;
-    import org.apache.royale.events.Event;
-
-    //--------------------------------------
-    //  Events
-    //--------------------------------------
-
-    /**
-     *  Dispatched when the user checks or un-checks the CheckBox.
-     *
-     *  @langversion 3.0
-     *  @playerversion Flash 10.2
-     *  @playerversion AIR 2.6
-     *  @productversion Royale 0.9.4
-     */
-       [Event(name="change", type="org.apache.royale.events.Event")]
-
+    import org.apache.royale.jewel.supportClasses.button.SelectableButtonBase;
+    
     /**
-     *  The CheckBox class implements the common user interface
-     *  control. The CheckBox includes its text label.
-     *
-     *  @toplevel
+     *  The Jewel CheckBox consists of a box, that can contain a check mark or 
not, and an optional label.
+     *  
+     *  When a user clicks or touches this control or its associated text, the 
CheckBox changes 
+     *  its state from checked to unchecked or from unchecked to checked, 
communicating
+     *  clearly a binary condition.
+     *  
+     *  Checkboxes can appear in groups (but not necesarily), and can be
+     *  selected and deselected individually.
+     *  
      *  @langversion 3.0
      *  @playerversion Flash 10.2
      *  @playerversion AIR 2.6
      *  @productversion Royale 0.9.4
      */
-    COMPILE::SWF
-       public class CheckBox extends UIButtonBase implements ISelectable, 
IClassSelectorListSupport
-       {
+    public class CheckBox extends SelectableButtonBase
+    {
         /**
          *  Constructor.
-         *
+         *  
          *  @langversion 3.0
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
@@ -76,198 +62,51 @@ package org.apache.royale.jewel
                {
                        super();
 
-            classSelectorList = new ClassSelectorList(this);
-
-                       
addEventListener(org.apache.royale.events.MouseEvent.CLICK, 
internalMouseHandler);
-               }
-
-        /**
-                * @private
-                */
-        private function 
internalMouseHandler(event:org.apache.royale.events.MouseEvent) : void
-               {
-                       selected = !selected;
-                       dispatchEvent(new Event(Event.CHANGE));
-               }
-
-        protected var classSelectorList:ClassSelectorList;
-
-        /**
-         * Add a class selector to the list.
-         * 
-         * @param name Name of selector to add.
-         * 
-         * @langversion 3.0
-         * @playerversion Flash 10.2
-         * @playerversion AIR 2.6
-         * @productversion Royale 0.9.6
-         */
-        public function addClass(name:String):void
-        {
-            // To implement. Need to implement this interface or extensions 
will not compile
-        }
-
-        /**
-         * Removes a class selector from the list.
-         * 
-         * @param name Name of selector to remove.
-         *
-         * @royaleignorecoercion HTMLElement
-         * @royaleignorecoercion DOMTokenList
-         * 
-         * @langversion 3.0
-         * @playerversion Flash 10.2
-         * @playerversion AIR 2.6
-         * @productversion Royale 0.9.6
-         */
-        public function removeClass(name:String):void
-        {
-            // To implement. Need to implement this interface or extensions 
will not compile
-        }
-
-        /**
-         * Add or remove a class selector to/from the list.
-         * 
-         * @param name Name of selector to add or remove.
-         * @param value True to add, False to remove.
-         * 
-         * @langversion 3.0
-         * @playerversion Flash 10.2
-         * @playerversion AIR 2.6
-         * @productversion Royale 0.9.6
-         */
-        public function toggleClass(name:String, value:Boolean):void
-        {
-            // To implement. Need to implement this interface or extensions 
will not compile
-        }
-
-        /**
-                *  Search for the name in the element class list 
-                *
-         *  @param name Name of selector to find.
-         *  @return return true if the name is found or false otherwise.
-         * 
-                *  @langversion 3.0
-                *  @playerversion Flash 10.2
-                *  @playerversion AIR 2.6
-                *  @productversion Royale 0.9.6
-                */
-               public function containsClass(name:String):Boolean
-        {
-            return false;
+            typeNames = "jewel checkbox";
         }
 
-        /**
-         *  The text label for the CheckBox.
-         *
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9.4
-         */
-               public function get text():String
-               {
-                       return IToggleButtonModel(model).text;
-               }
-        /**
-         *  @private
-         */
-               public function set text(value:String):void
-               {
-                       IToggleButtonModel(model).text = value;
-               }
-
         [Bindable("change")]
         /**
-         *  <code>true</code> if the check mark is displayed.
-         *
+         *  <code>true</code> if the check mark is displayed, 
<code>false</code> otherwise.
+         *  
          *  @default false
+         *  
          *  @langversion 3.0
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
          *  @productversion Royale 0.9.4
          */
-               public function get selected():Boolean
+               override public function get selected():Boolean
                {
+            COMPILE::SWF
+            {
                        return IToggleButtonModel(model).selected;
+            }
+            COMPILE::JS
+            {
+            return input.checked;
+            }
                }
         /**
          *  @private
          */
-               public function set selected(value:Boolean):void
+               override public function set selected(value:Boolean):void
                {
+            COMPILE::SWF
+            {
                        IToggleButtonModel(model).selected = value;
+            }
+            COMPILE::JS
+            {
+            if(input.checked == value)
+                return;
+            input.checked = value;
+            dispatchEvent(new Event(Event.CHANGE));
+            }
                }
 
         /**
-         *  The value associated with the CheckBox.
-         *
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9
-         */
-        public function get value():String
-        {
-            return IToggleButtonModel(model).html;
-        }
-        public function set value(newValue:String):void
-        {
-            IToggleButtonModel(model).html = newValue;
-        }
-       }
-    
-    //--------------------------------------
-    //  Events
-    //--------------------------------------
-    
-    /**
-     *  Dispatched when the user checks or un-checks the CheckBox.
-     *
-     *  @langversion 3.0
-     *  @playerversion Flash 10.2
-     *  @playerversion AIR 2.6
-     *  @productversion Royale 0.9.4
-     */
-       [Event(name="change", type="org.apache.royale.events.Event")]
-    
-    /**
-     *  The CheckBox class provides a Jewel UI-like appearance for a CheckBox.
-     *
-     *  A checkbox consists of a small square and, typically, text that 
clearly 
-     *  communicates a binary condition that will be set or unset when the 
user 
-     *  clicks or touches it.
-     *  
-     *  Checkboxes typically, but not necessarily, appear in groups, and can be
-     *  selected and deselected individually. The Jewel checkbox component 
allows
-     *  you to add display and click effects.
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10.2
-     *  @playerversion AIR 2.6
-     *  @productversion Royale 0.9.4
-     */
-    COMPILE::JS
-    public class CheckBox extends StyledUIBase implements ISelectable
-    {
-        /**
-         *  Constructor.
-         *  
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9.4
-         */
-               public function CheckBox()
-               {
-                       super();
-
-            typeNames = "jewel checkbox";
-        }
-
-        protected var textNode:Text;
-        /**
-         *  The text label for the CheckBox.
+         *  The string used as a label for the CheckBox.
          *
          *  @royaleignorecoercion Text
          *  
@@ -278,13 +117,26 @@ package org.apache.royale.jewel
          */
                public function get text():String
                {
+            COMPILE::SWF
+            {
+            return IToggleButtonModel(model).text;
+            }
+            COMPILE::JS
+            {
             return textNode ? textNode.nodeValue : "";
+            }
                }
         /**
          *  @private
          */
         public function set text(value:String):void
                {
+            COMPILE::SWF
+            {
+               IToggleButtonModel(model).text = value;
+            }
+            COMPILE::JS
+            {
             if(!textNode)
             {
                 textNode = document.createTextNode('') as Text;
@@ -292,6 +144,7 @@ package org.apache.royale.jewel
             }
             
             textNode.nodeValue = value;
+            }
                }
 
         /**
@@ -304,46 +157,54 @@ package org.apache.royale.jewel
          */
         public function get value():String
         {
+            COMPILE::SWF
+            {
+            return IToggleButtonModel(model).html;
+            }
+            COMPILE::JS
+            {
             return input.value;
+            }
         }
         public function set value(newValue:String):void
         {
+            COMPILE::SWF
+            {
+            IToggleButtonModel(model).html = newValue;
+            }
+            COMPILE::JS
+            {
             input.value = newValue;
+            }
         }
 
-        [Bindable("change")]
+        COMPILE::JS
         /**
-         *  <code>true</code> if the check mark is displayed.
-         *
-         *  @default false
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9.4
+         * the org.apache.royale.core.HTMLElementWrapper#element for this 
component
+         * added to the positioner. Is a HTMLInputElement.
          */
-               public function get selected():Boolean
-               {
-            return input.checked;
-               }
+        protected var input:HTMLInputElement;
+
+        COMPILE::JS
         /**
-         * @private
+         * a HTMLSpanElement decorator for this component
+         * added to the positioner.
          */
-        public function set selected(value:Boolean):void
-        {
-            if(input.checked == value)
-                return;
-            input.checked = value;
-            dispatchEvent(new Event(Event.CHANGE));
-        }
-
-        protected var input:HTMLInputElement;
         protected var checkbox:HTMLSpanElement;
         
+        COMPILE::JS
+        /**
+         * a Text node added to the checkbox HTMLSpanElement.
+         * It's creation is deferred since Checkboxes sometimes are used 
without labels.
+         */
+        protected var textNode:Text;
+
         /**
          * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
          * @royaleignorecoercion HTMLInputElement
          * @royaleignorecoercion HTMLSpanElement
          */
+        COMPILE::JS
         override protected function createElement():WrappedHTMLElement
         {
             input = addElementToWrapper(this,'input') as HTMLInputElement;
@@ -353,6 +214,7 @@ package org.apache.royale.jewel
             return element;
         }
 
+        COMPILE::JS
         private var _positioner:WrappedHTMLElement;
         /**
          *  @copy org.apache.royale.core.IUIBase#positioner
@@ -362,10 +224,12 @@ package org.apache.royale.jewel
          *  @playerversion AIR 2.6
          *  @productversion Royale 0.9.4
          */
+        COMPILE::JS
                override public function get positioner():WrappedHTMLElement
                {
                        return _positioner;
                }
+        COMPILE::JS
                override public function set 
positioner(value:WrappedHTMLElement):void
                {
                        _positioner = value;
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/RadioButton.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/RadioButton.as
index d83ddfe..57c11b4 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/RadioButton.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/RadioButton.as
@@ -23,209 +23,97 @@ package org.apache.royale.jewel
     import flash.utils.Dictionary;
 
     import org.apache.royale.core.IValueToggleButtonModel;
-    import org.apache.royale.core.UIButtonBase;
-    import org.apache.royale.utils.ClassSelectorList;
-    import org.apache.royale.utils.IClassSelectorListSupport;
     }
 
     COMPILE::JS
     {
-    import org.apache.royale.core.StyledUIBase;
     import org.apache.royale.core.WrappedHTMLElement;
+    import org.apache.royale.events.Event;
     import org.apache.royale.html.util.addElementToWrapper;
     }
 
-    import org.apache.royale.core.ISelectable;
-    import org.apache.royale.events.Event;
     import org.apache.royale.events.MouseEvent;
-
-    //--------------------------------------
-    //  Events
-    //--------------------------------------
-
-    /**
-     *  Dispatched when RadioButton is being selected/unselected.
-     *
-     *  @langversion 3.0
-     *  @playerversion Flash 10.2
-     *  @playerversion AIR 2.6
-     *  @productversion Royale 0.9.4
-     */
-    [Event(name="change", type="org.apache.royale.events.Event")]
-
+    import org.apache.royale.jewel.supportClasses.button.SelectableButtonBase;
+    
     /**
-     *  The Jewel radio button component in SWF is a specialized button.
-     * 
-     *  A radio button consists of a small circle and, typically, text that 
clearly communicates a
+     *  The Jewel RadioButton control lets the user make a single choice 
within a set of mutually exclusive choices.
+     *  
+     *  A RadioButton consists of a circle and, typically, text that clearly 
communicates a
      *  condition that will be set when the user clicks or touches it. Radio 
buttons
-     *  always appear in groups of two or more and, while they can be 
individually
-     *  selected, can only be deselected by selecting a different radio button 
in the
-     *  same group (which deselects all other radio buttons in the group).
+     *  always appear in groups of two or more with the same 
<code>groupName</code> propert. 
+     *  While they can be individually selected, can only be deselected by 
selecting 
+     *  a different RadioButton in the same group (which deselects the rest of 
RadioButton).
      *  
      *  @langversion 3.0
      *  @playerversion Flash 10.2
      *  @playerversion AIR 2.6
      *  @productversion Royale 0.9.4
      */
-    COMPILE::SWF
-       public class RadioButton extends UIButtonBase implements ISelectable, 
IClassSelectorListSupport
-       {
+    public class RadioButton extends SelectableButtonBase
+    {
         /**
-                *  constructor.
-                *
-                *  @langversion 3.0
-                *  @playerversion Flash 10.2
-                *  @playerversion AIR 2.6
-                *  @productversion Royale 0.9.4
-                */
+         *  Constructor.
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.9.4
+         */
                public function RadioButton()
                {
             super();
 
-            classSelectorList = new ClassSelectorList(this);
-
             typeNames = "jewel radiobutton";
-
-                       
addEventListener(org.apache.royale.events.MouseEvent.CLICK, 
internalMouseHandler);
-               }
+        }
 
         /**
                 * @private
                 */
-               private function internalMouseHandler(event:MouseEvent) : void
+        COMPILE::SWF
+               override protected function 
internalMouseHandler(event:MouseEvent):void
                {
                        // prevent radiobutton from being turned off by a click
                        if( !selected ) {
-                               selected = !selected;
-                               dispatchEvent(new Event(Event.CHANGE));
+                               super.internalMouseHandler(event);
                        }
-               }
-
-        protected var classSelectorList:ClassSelectorList;
-
-        /**
-         * Add a class selector to the list.
-         * 
-         * @param name Name of selector to add.
-         * 
-         * @langversion 3.0
-         * @playerversion Flash 10.2
-         * @playerversion AIR 2.6
-         * @productversion Royale 0.9.6
-         */
-        public function addClass(name:String):void
-        {
-            // To implement. Need to implement this interface or extensions 
will not compile
         }
 
-        /**
-         * Removes a class selector from the list.
-         * 
-         * @param name Name of selector to remove.
-         *
-         * @royaleignorecoercion HTMLElement
-         * @royaleignorecoercion DOMTokenList
-         * 
-         * @langversion 3.0
-         * @playerversion Flash 10.2
-         * @playerversion AIR 2.6
-         * @productversion Royale 0.9.6
-         */
-        public function removeClass(name:String):void
-        {
-            // To implement. Need to implement this interface or extensions 
will not compile
-        }
-
-        /**
-         * Add or remove a class selector to/from the list.
-         * 
-         * @param name Name of selector to add or remove.
-         * @param value True to add, False to remove.
-         * 
-         * @langversion 3.0
-         * @playerversion Flash 10.2
-         * @playerversion AIR 2.6
-         * @productversion Royale 0.9.6
-         */
-        public function toggleClass(name:String, value:Boolean):void
-        {
-            // To implement. Need to implement this interface or extensions 
will not compile
-        }
-
-        /**
-                *  Search for the name in the element class list 
-                *
-         *  @param name Name of selector to find.
-         *  @return return true if the name is found or false otherwise.
-         * 
-                *  @langversion 3.0
-                *  @playerversion Flash 10.2
-                *  @playerversion AIR 2.6
-                *  @productversion Royale 0.9.6
-                */
-               public function containsClass(name:String):Boolean
-        {
-            return false;
-        }
-
-               protected static var dict:Dictionary = new Dictionary(true);
-
-               /**
-                *  The name of the group. Only one RadioButton in a group is 
selected.
-                *
-                *  @langversion 3.0
-                *  @playerversion Flash 10.2
-                *  @playerversion AIR 2.6
-                *  @productversion Royale 0.9.4
-                */
-               public function get groupName() : String
-               {
-                       return IValueToggleButtonModel(model).groupName;
-               }
-               public function set groupName(value:String) : void
-               {
-                       IValueToggleButtonModel(model).groupName = value;
-               }
-
-               /**
-                *  The string used as a label for the RadioButton.
-                *
-                *  @langversion 3.0
-                *  @playerversion Flash 10.2
-                *  @playerversion AIR 2.6
-                *  @productversion Royale 0.9.4
-                */
-               public function get text():String
-               {
-                       return IValueToggleButtonModel(model).text;
-               }
-               public function set text(value:String):void
-               {
-                       IValueToggleButtonModel(model).text = value;
-               }
-
+        COMPILE::SWF
+        protected static var dict:Dictionary = new Dictionary(true);
                /**
                 *  Whether or not the RadioButton instance is selected. 
Setting this property
                 *  causes the currently selected RadioButton in the same group 
to lose the
                 *  selection.
+         * 
+         *  <code>true</code> if the radio mark is displayed, 
<code>false</code> otherwise.
                 *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
                 */
-               public function get selected():Boolean
+        [Bindable("change")]
+               override public function get selected():Boolean
                {
+            COMPILE::SWF
+            {
                        return IValueToggleButtonModel(model).selected;
+            }
+            COMPILE::JS
+            {
+            return icon.checked;
+            }
                }
-               public function set selected(selValue:Boolean):void
+               override public function set selected(selValue:Boolean):void
                {
+            COMPILE::SWF
+            {
                        IValueToggleButtonModel(model).selected = selValue;
 
                        // if this button is being selected, its value should 
become
                        // its group's selectedValue
                        if( selValue ) {
-                               for each(var 
rb:org.apache.royale.jewel.RadioButton in dict)
+                               for each(var rb:RadioButton in dict)
                                {
                                        if( rb.groupName == groupName )
                                        {
@@ -233,28 +121,19 @@ package org.apache.royale.jewel
                                        }
                                }
                        }
+            }
+            COMPILE::JS
+            {
+            if(icon.checked == value) {
+                return;
+            }
+            icon.checked = value;
+            dispatchEvent(new Event(Event.CHANGE));
+            }
                }
 
-               /**
-                *  The value associated with the RadioButton. For example, 
RadioButtons with labels,
-                *  "Red", "Green", and "Blue" might have the values 0, 1, and 
2 respectively.
-                *
-                *  @langversion 3.0
-                *  @playerversion Flash 10.2
-                *  @playerversion AIR 2.6
-                *  @productversion Royale 0.9.4
-                */
-               public function get value():Object
-               {
-                       return IValueToggleButtonModel(model).value;
-               }
-               public function set value(newValue:Object):void
-               {
-                       IValueToggleButtonModel(model).value = newValue;
-               }
-
-               /**
-                *  The group's currently selected value.
+        /**
+                *  The currently selected value in the group.
                 *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
@@ -263,112 +142,90 @@ package org.apache.royale.jewel
                 */
                public function get selectedValue():Object
                {
+            COMPILE::SWF
+            {
                        return IValueToggleButtonModel(model).selectedValue;
+            }
+            COMPILE::JS
+            {
+            var groupName:String = icon.name as String;
+            var buttons:NodeList = document.getElementsByName(groupName);
+            var n:int = buttons.length;
+
+            for (var i:int = 0; i < n; i++)
+            {
+                if (buttons[i].checked)
+                {
+                    return buttons[i].value;
+                }
+            }
+            return null;
+            }
                }
+        /**
+         * @royaleignorecoercion HTMLInputElement
+         */
                public function set selectedValue(newValue:Object):void
                {
+            COMPILE::SWF
+            {
                        // a radio button is really selected when its value 
matches that of the group's value
                        IValueToggleButtonModel(model).selected = (newValue == 
value);
                        IValueToggleButtonModel(model).selectedValue = newValue;
-               }
-
-               /**
-                * @private
-                */
-               override public function addedToParent():void
-               {
-            super.addedToParent();
-
-            // if this instance is selected, set the local selectedValue to
-                       // this instance's value
-                       if( selected ) selectedValue = value;
-
-                       else {
-
-                               // make sure this button's selectedValue is set 
from its group's selectedValue
-                               // to keep it in sync with the rest of the 
buttons in its group.
-                               for each(var 
rb:org.apache.royale.jewel.RadioButton in dict)
-                               {
-                                       if( rb.groupName == groupName )
-                                       {
-                                               selectedValue = 
rb.selectedValue;
-                                               break;
-                                       }
-                               }
-                       }
+            }
+            COMPILE::JS
+            {
+            var groupName:String = icon.name as String;
+            var buttons:NodeList = document.getElementsByName(groupName);
+            var n:int = buttons.length;
 
-                       dict[this] = this;
+            for (var i:int = 0; i < n; i++)
+            {
+                if (buttons[i].value === value)
+                {
+                    buttons[i].checked = true;
+                    break;
+                }
+            }
+            }
                }
-       }
-    
-    //--------------------------------------
-    //  Events
-    //--------------------------------------
-
-    /**
-     *  Dispatched when RadioButton is being selected/unselected.
-     *
-     *  @langversion 3.0
-     *  @playerversion Flash 10.2
-     *  @playerversion AIR 2.6
-     *  @productversion Royale 0.9.4
-     */
-    [Event(name="change", type="org.apache.royale.events.Event")]
-
-    /**
-     *  The Jewel radio button component in JS is an enhanced version of the
-     *  standard HTML <input type="radio">, or "radio button" element.
-     * 
-     *  A radio button consists of a small circle and, typically, text that 
clearly communicates a
-     *  condition that will be set when the user clicks or touches it. Radio 
buttons
-     *  always appear in groups of two or more and, while they can be 
individually
-     *  selected, can only be deselected by selecting a different radio button 
in the
-     *  same group (which deselects all other radio buttons in the group).
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10.2
-     *  @playerversion AIR 2.6
-     *  @productversion Royale 0.9.4
-     */
-    COMPILE::JS
-    public class RadioButton extends StyledUIBase implements ISelectable
-    {
-        /**
-         *  Constructor.
-         *
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9.4
-         */
-               public function RadioButton()
-               {
-            super();
-
-            typeNames = "jewel radiobutton";
-        }
         
         /**
-         *  The text label for the RadioButton.
-         *
+                *  The string used as a label for the RadioButton.
+                *  
          *  @royaleignorecoercion Text
          *  
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9.4
-         */
-        public function get text():String
-        {
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9.4
+                */
+               public function get text():String
+               {
+            COMPILE::SWF
+            {
+                       return IValueToggleButtonModel(model).text;
+            }
+            COMPILE::JS
+            {
             return textNode.nodeValue;
-        }
-        public function set text(value:String):void
-        {
+            }
+               }
+               public function set text(value:String):void
+               {
+            COMPILE::SWF
+            {
+                       IValueToggleButtonModel(model).text = value;
+            }
+            COMPILE::JS
+            {
             textNode.nodeValue = value;
-        }
+            }
+               }
 
         /**
-         *  The value associated with the RadioButton.
+         *  The value associated with the RadioButton. For example, 
RadioButtons with labels,
+                *  "Red", "Green", and "Blue" might have the values 0, 1, and 
2 respectively.
          *
          *  @langversion 3.0
          *  @playerversion Flash 10.2
@@ -377,71 +234,30 @@ package org.apache.royale.jewel
          */
         public function get value():Object
         {
+            COMPILE::SWF
+            {
+            return IValueToggleButtonModel(model).value;
+            }
+            COMPILE::JS
+            {
             return icon.value;
+            }
         }
         public function set value(value:Object):void
         {
-            icon.value = String(value);
-        }
-
-        /**
-         *  <code>true</code> if the radio mark is displayed.
-         *  
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9.4
-         * 
-         *  @export
-         */
-        public function get selected():Boolean
-        {
-            return icon.checked;
-        }
-        public function set selected(value:Boolean):void
-        {
-            if(icon.checked == value)
-                return;
-            icon.checked = value;
-            dispatchEvent(new Event(Event.CHANGE));
-        }
-
-        public function get selectedValue():Object
-        {
-            var groupName:String = icon.name as String;
-            var buttons:NodeList = document.getElementsByName(groupName);
-            var n:int = buttons.length;
-
-            for (var i:int = 0; i < n; i++)
+            COMPILE::SWF
             {
-                if (buttons[i].checked)
-                {
-                    return buttons[i].value;
-                }
+            IValueToggleButtonModel(model).value = value;
             }
-            return null;
-        }
-        /**
-         * @royaleignorecoercion HTMLInputElement
-         */
-        public function set selectedValue(value:Object):void
-        {
-            var groupName:String = icon.name as String;
-            var buttons:NodeList = document.getElementsByName(groupName);
-            var n:int = buttons.length;
-
-            for (var i:int = 0; i < n; i++)
+            COMPILE::JS
             {
-                if (buttons[i].value === value)
-                {
-                    buttons[i].checked = true;
-                    break;
-                }
+            icon.value = String(value);
             }
         }
-
+        
         /**
-         *  The name of the group to which this radio belongs
+         *  The name of the group to which this radio belongs.
+         *  Only one RadioButton in a group can be selected.
          *
          *  @langversion 3.0
          *  @playerversion Flash 10.2
@@ -450,16 +266,46 @@ package org.apache.royale.jewel
          */
         public function get groupName():String
         {
+            COMPILE::SWF
+            {
+            return IValueToggleButtonModel(model).groupName;
+            }
+            COMPILE::JS
+            {
             return icon.name as String;
+            }
         }
         public function set groupName(value:String):void
         {
+            COMPILE::SWF
+            {
+            IValueToggleButtonModel(model).groupName = value;
+            }
+            COMPILE::JS
+            {
             icon.name = value;
+            }
         }
 
-        private var radio:HTMLSpanElement;
-        private var icon:HTMLInputElement;
-        private var textNode:Text;
+        COMPILE::JS
+        /**
+         * the org.apache.royale.core.HTMLElementWrapper#element for this 
component
+         * added to the positioner. Is a HTMLInputElement.
+         */
+        protected var icon:HTMLInputElement;
+        
+        COMPILE::JS
+        /**
+         * a HTMLSpanElement decorator for this component
+         * added to the positioner.
+         */
+        protected var radio:HTMLSpanElement;
+
+        COMPILE::JS
+        /**
+         * a Text node added to the radio HTMLSpanElement
+         */
+        protected var textNode:Text;
 
         /**
          * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
@@ -467,6 +313,7 @@ package org.apache.royale.jewel
          * @royaleignorecoercion HTMLSpanElement
          * @royaleignorecoercion Text
          */
+        COMPILE::JS
         override protected function createElement():WrappedHTMLElement
         {
             icon = addElementToWrapper(this, 'input') as HTMLInputElement;
@@ -483,6 +330,7 @@ package org.apache.royale.jewel
             return element;
         }
 
+        COMPILE::JS
         private var _positioner:WrappedHTMLElement;
         /**
          *  @copy org.apache.royale.core.IUIBase#positioner
@@ -492,10 +340,12 @@ package org.apache.royale.jewel
          *  @playerversion AIR 2.6
          *  @productversion Royale 0.9.4
          */
+        COMPILE::JS
                override public function get positioner():WrappedHTMLElement
                {
                        return _positioner;
                }
+        COMPILE::JS
         override public function set positioner(value:WrappedHTMLElement):void
                {
                        _positioner = value;
@@ -507,6 +357,7 @@ package org.apache.royale.jewel
         /**
          * @copy org.apache.royale.events.EventDispatcher#addEventListener
          */
+        COMPILE::JS
         override public function addEventListener(type:String, 
handler:Function, opt_capture:Boolean = false, opt_handlerScope:Object = 
null):void
         {
             if (type == MouseEvent.CLICK)
@@ -515,8 +366,42 @@ package org.apache.royale.jewel
             }
             else
             {
-               super.addEventListener(type, handler, opt_capture, 
opt_handlerScope);
+                super.addEventListener(type, handler, opt_capture, 
opt_handlerScope);
             }
         }
+
+        /**
+         *  @copy org.apache.royale.core.IParent#addElement()
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.9.6
+         */
+        COMPILE::SWF
+               override public function addedToParent():void
+               {
+            super.addedToParent();
+
+            // if this instance is selected, set the local selectedValue to
+                       // this instance's value
+                       if(selected) {
+                selectedValue = value;
+            }
+                       else {
+                               // make sure this button's selectedValue is set 
from its group's selectedValue
+                               // to keep it in sync with the rest of the 
buttons in its group.
+                               for each(var rb:RadioButton in dict)
+                               {
+                                       if(rb.groupName == groupName)
+                                       {
+                                               selectedValue = 
rb.selectedValue;
+                                               break;
+                                       }
+                               }
+                       }
+
+                       dict[this] = this;
+               }
     }
 }
\ No newline at end of file
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/CheckBox.as 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/button/SelectableButtonBase.as
similarity index 50%
copy from 
frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/CheckBox.as
copy to 
frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/button/SelectableButtonBase.as
index b195417..061ff56 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/CheckBox.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/button/SelectableButtonBase.as
@@ -16,13 +16,12 @@
 //  limitations under the License.
 //
 
////////////////////////////////////////////////////////////////////////////////
-package org.apache.royale.jewel
+package org.apache.royale.jewel.supportClasses.button
 {
     COMPILE::SWF
     {
     import org.apache.royale.core.UIButtonBase;
     import org.apache.royale.events.MouseEvent;
-    import org.apache.royale.core.IToggleButtonModel;
     import org.apache.royale.utils.ClassSelectorList;
     import org.apache.royale.utils.IClassSelectorListSupport;
     }
@@ -30,8 +29,6 @@ package org.apache.royale.jewel
     COMPILE::JS
     {
     import org.apache.royale.core.StyledUIBase;
-    import org.apache.royale.core.WrappedHTMLElement;
-    import org.apache.royale.html.util.addElementToWrapper;
     }
 
     import org.apache.royale.core.ISelectable;
@@ -42,27 +39,27 @@ package org.apache.royale.jewel
     //--------------------------------------
 
     /**
-     *  Dispatched when the user checks or un-checks the CheckBox.
+     *  Dispatched when the user selected or deselects this component.
      *
      *  @langversion 3.0
      *  @playerversion Flash 10.2
      *  @playerversion AIR 2.6
-     *  @productversion Royale 0.9.4
+     *  @productversion Royale 0.9.6
      */
        [Event(name="change", type="org.apache.royale.events.Event")]
 
     /**
-     *  The CheckBox class implements the common user interface
-     *  control. The CheckBox includes its text label.
+     *  The SelectableButtonBase is a support class (not for direct use) and 
implements the ISelectable interface
+     *  to be override in subclasses. Jewel CheckBox and RadioButtons are 
direct extensions of this class.
      *
      *  @toplevel
      *  @langversion 3.0
      *  @playerversion Flash 10.2
      *  @playerversion AIR 2.6
-     *  @productversion Royale 0.9.4
+     *  @productversion Royale 0.9.6
      */
     COMPILE::SWF
-       public class CheckBox extends UIButtonBase implements ISelectable, 
IClassSelectorListSupport
+       public class SelectableButtonBase extends UIButtonBase implements 
ISelectable, IClassSelectorListSupport
        {
         /**
          *  Constructor.
@@ -70,21 +67,20 @@ package org.apache.royale.jewel
          *  @langversion 3.0
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9.4
+         *  @productversion Royale 0.9.6
          */
-               public function CheckBox()
+               public function SelectableButtonBase()
                {
                        super();
 
             classSelectorList = new ClassSelectorList(this);
-
-                       
addEventListener(org.apache.royale.events.MouseEvent.CLICK, 
internalMouseHandler);
+                       addEventListener(MouseEvent.CLICK, 
internalMouseHandler);
                }
 
         /**
                 * @private
                 */
-        private function 
internalMouseHandler(event:org.apache.royale.events.MouseEvent) : void
+        protected function 
internalMouseHandler(event:org.apache.royale.events.MouseEvent):void
                {
                        selected = !selected;
                        dispatchEvent(new Event(Event.CHANGE));
@@ -154,67 +150,32 @@ package org.apache.royale.jewel
                 */
                public function containsClass(name:String):Boolean
         {
+            // To implement. Need to implement this interface or extensions 
will not compile
             return false;
         }
 
         /**
-         *  The text label for the CheckBox.
-         *
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9.4
-         */
-               public function get text():String
-               {
-                       return IToggleButtonModel(model).text;
-               }
-        /**
-         *  @private
-         */
-               public function set text(value:String):void
-               {
-                       IToggleButtonModel(model).text = value;
-               }
-
-        [Bindable("change")]
-        /**
-         *  <code>true</code> if the check mark is displayed.
+         *  <code>true</code> if selected, <code>false</code> otherwise.
          *
          *  @default false
+         *  
          *  @langversion 3.0
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9.4
+         *  @productversion Royale 0.9.6
          */
                public function get selected():Boolean
                {
-                       return IToggleButtonModel(model).selected;
+            // to implement in subclasses
+                       return false;
                }
         /**
          *  @private
          */
                public function set selected(value:Boolean):void
                {
-                       IToggleButtonModel(model).selected = value;
+                       // to implement in subclasses
                }
-
-        /**
-         *  The value associated with the CheckBox.
-         *
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9
-         */
-        public function get value():String
-        {
-            return IToggleButtonModel(model).html;
-        }
-        public function set value(newValue:String):void
-        {
-            IToggleButtonModel(model).html = newValue;
-        }
        }
     
     //--------------------------------------
@@ -227,28 +188,22 @@ package org.apache.royale.jewel
      *  @langversion 3.0
      *  @playerversion Flash 10.2
      *  @playerversion AIR 2.6
-     *  @productversion Royale 0.9.4
+     *  @productversion Royale 0.9.6
      */
        [Event(name="change", type="org.apache.royale.events.Event")]
     
     /**
-     *  The CheckBox class provides a Jewel UI-like appearance for a CheckBox.
+     *  The SelectableButtonBase is a support class (not for direct use) and 
implements the ISelectable interface
+     *  to be override in subclasses. Jewel CheckBox and RadioButtons are 
direct extensions of this class.
      *
-     *  A checkbox consists of a small square and, typically, text that 
clearly 
-     *  communicates a binary condition that will be set or unset when the 
user 
-     *  clicks or touches it.
-     *  
-     *  Checkboxes typically, but not necessarily, appear in groups, and can be
-     *  selected and deselected individually. The Jewel checkbox component 
allows
-     *  you to add display and click effects.
-     *  
+     *  @toplevel
      *  @langversion 3.0
      *  @playerversion Flash 10.2
      *  @playerversion AIR 2.6
-     *  @productversion Royale 0.9.4
+     *  @productversion Royale 0.9.6
      */
     COMPILE::JS
-    public class CheckBox extends StyledUIBase implements ISelectable
+    public class SelectableButtonBase extends StyledUIBase implements 
ISelectable
     {
         /**
          *  Constructor.
@@ -256,122 +211,34 @@ package org.apache.royale.jewel
          *  @langversion 3.0
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9.4
+         *  @productversion Royale 0.9.6
          */
-               public function CheckBox()
+               public function SelectableButtonBase()
                {
                        super();
-
-            typeNames = "jewel checkbox";
         }
-
-        protected var textNode:Text;
-        /**
-         *  The text label for the CheckBox.
-         *
-         *  @royaleignorecoercion Text
-         *  
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9.4
-         */
-               public function get text():String
-               {
-            return textNode ? textNode.nodeValue : "";
-               }
-        /**
-         *  @private
-         */
-        public function set text(value:String):void
-               {
-            if(!textNode)
-            {
-                textNode = document.createTextNode('') as Text;
-                checkbox.appendChild(textNode);
-            }
-            
-            textNode.nodeValue = value;
-               }
-
-        /**
-         *  The value associated with the CheckBox.
-         *
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9.4
-         */
-        public function get value():String
-        {
-            return input.value;
-        }
-        public function set value(newValue:String):void
-        {
-            input.value = newValue;
-        }
-
-        [Bindable("change")]
+        
         /**
-         *  <code>true</code> if the check mark is displayed.
+         *  <code>true</code> if selected, <code>false</code> otherwise.
          *
          *  @default false
+         *  
          *  @langversion 3.0
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9.4
+         *  @productversion Royale 0.9.6
          */
                public function get selected():Boolean
                {
-            return input.checked;
+            // to implement in subclasses
+            return false;
                }
         /**
          * @private
          */
         public function set selected(value:Boolean):void
         {
-            if(input.checked == value)
-                return;
-            input.checked = value;
-            dispatchEvent(new Event(Event.CHANGE));
-        }
-
-        protected var input:HTMLInputElement;
-        protected var checkbox:HTMLSpanElement;
-        
-        /**
-         * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
-         * @royaleignorecoercion HTMLInputElement
-         * @royaleignorecoercion HTMLSpanElement
-         */
-        override protected function createElement():WrappedHTMLElement
-        {
-            input = addElementToWrapper(this,'input') as HTMLInputElement;
-            input.type = 'checkbox';
-            checkbox = document.createElement('span') as HTMLSpanElement;
-            positioner = document.createElement('label') as 
WrappedHTMLElement;   
-            return element;
-        }
-
-        private var _positioner:WrappedHTMLElement;
-        /**
-         *  @copy org.apache.royale.core.IUIBase#positioner
-         *
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9.4
-         */
-               override public function get positioner():WrappedHTMLElement
-               {
-                       return _positioner;
-               }
-               override public function set 
positioner(value:WrappedHTMLElement):void
-               {
-                       _positioner = value;
-            _positioner.royale_wrapper = this;
-                       _positioner.appendChild(element);
-            _positioner.appendChild(checkbox);
-               }
+            // to implement in subclasses
+        }      
     }
 }

Reply via email to