Updated Branches: refs/heads/develop e6c5be9c2 -> 97a9298cc
FLEX-23303: Added new minor enhancement selectedIndex. Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/97a9298c Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/97a9298c Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/97a9298c Branch: refs/heads/develop Commit: 97a9298cc314f752763b06720f5481b805e41045 Parents: e6c5be9 Author: Mark Kessler <kesslerconsult...@gmail.com> Authored: Sun Apr 21 22:09:08 2013 -0400 Committer: Mark Kessler <kesslerconsult...@gmail.com> Committed: Sun Apr 21 22:10:24 2013 -0400 ---------------------------------------------------------------------- .../spark/src/spark/components/RadioButtonGroup.as | 54 +++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/97a9298c/frameworks/projects/spark/src/spark/components/RadioButtonGroup.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/spark/src/spark/components/RadioButtonGroup.as b/frameworks/projects/spark/src/spark/components/RadioButtonGroup.as index e562a8a..2fb1526 100644 --- a/frameworks/projects/spark/src/spark/components/RadioButtonGroup.as +++ b/frameworks/projects/spark/src/spark/components/RadioButtonGroup.as @@ -277,6 +277,58 @@ public class RadioButtonGroup extends EventDispatcher implements IMXMLObject return radioButtons.length; } + + //---------------------------------- + // selectedIndex + //---------------------------------- + + /** + * @private + */ + private var _selectedIndex:int = -1; + + [Bindable("change")] + [Bindable("valueCommit")] + [Inspectable(category="General")] + + /** + * The index of the selected RadioButton component in the group. + * If a RadioButton is not selected, this property is <code>-1</code>. + * + * @default -1 + * + * @langversion 3.0 + * @playerversion Flash 11.1 + * @playerversion AIR 3.4 + * @productversion Flex 4.10 + */ + public function get selectedIndex():int + { + return _selectedIndex; + } + + /** + * @private. + */ + public function set selectedIndex(newValue:int):void + { + if (newValue == _selectedIndex) + { + return; + } + + if (newValue == -1) + { + setSelection(null, false); + return; + } + + changeSelection(newValue, false) + + dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT)); + } + + //---------------------------------- // selectedValue //---------------------------------- @@ -569,6 +621,7 @@ public class RadioButtonGroup extends EventDispatcher implements IMXMLObject { _selection.selected = false; _selection = null; + _selectedIndex = -1; if (fireChange) dispatchEvent(new Event(Event.CHANGE)); } @@ -607,6 +660,7 @@ public class RadioButtonGroup extends EventDispatcher implements IMXMLObject // Fire a click event for the radio group. _selection = rb; _selection.selected = true; + _selectedIndex = index; if (fireChange) dispatchEvent(new Event(Event.CHANGE)); }