>我正在尝试创建一个包含图像和单选按钮的xmxl组件。主应用程序脚本将使用其中的几个组件。
我在尝试使无线电组正常工作时遇到问题。我已经在组件 mxml 文件中的 RadioButton groupName 属性上绑定了一个变量,以便我可以在主应用程序脚本中设置它。
这正常工作,因为当我按 Tab 键浏览每个单选组时,只有每个组的第一个单选按钮获得焦点。但是当我单击组中的每个单选按钮时,前一个按钮不会取消选择。
我已经读到我无法绑定组件 id,那么我还能如何在每个组中只选择一个单选按钮?我需要实现 IFocusManager 吗?
谢谢
每组 RadioButton 都需要为该组分配一个 RadioButtonGroup。单选按钮组确保一次只选择 1 个按钮。RadioButtonGroup 以 <fx:Declarations>
形式声明,是在 groupName 属性中分配的 RadioButtonGroup 的名称。
<fx:Declarations>
<s:RadioButtonGroup id="paymentType" itemClick="handlePayment(event);"/>
</fx:Declarations>
<s:VGroup paddingLeft="10" paddingTop="10">
<s:RadioButton groupName="paymentType"
id="payCheck"
value="check"
label="Pay by check"
width="150"/>
<s:RadioButton groupName="paymentType"
id="payCredit"
value="credit"
label="Pay by credit card"
width="150"/>
</s:VGroup>
Apache Flex 参考:http://flex.apache.org/asdoc/spark/components/RadioButtonGroup.html