自定义组件中的 RadioButton 功能 [英] RadioButton functionality in custom component
问题描述
我正在尝试创建一个包含图像和单选按钮的 xmxl 组件.主应用程序脚本将使用其中几个组件.
I am trying to create an xmxl component which contains an image and a radio button. The main application script will use several of these components.
我在尝试让 RadioGroup 正常运行时遇到问题.我在组件 mxml 文件中的 RadioButton groupName 属性上绑定了一个变量,因此我可以在主应用程序脚本中设置它.
I am having problems trying to get the RadioGroup to function properly. I have binded a variable on the RadioButton groupName attribute in the component mxml file so I can set this in the main application script.
当我浏览每个 RadioGroup 时,这会正常工作,只有每个组的第一个单选按钮获得焦点.但是当我点击组中的每个单选按钮时,前一个不会取消选择.
This functions properly as when I tab through each RadioGroup, only the first radiobutton of each group gets the focus. But when I click each radio button in a group, the previous one does not deselect.
我已经读到我无法绑定组件 ID,那么我还能如何实现在每组中只选择一个单选按钮?我需要实现 IFocusManager 吗?
I have read that I cannot bind component id's so how else can I achieve selecting only one radio button in each group? Do I need to implement IFocusManager?
谢谢
推荐答案
每组 RadioButton 都需要一个 RadioButtonGroup 分配给 groupName.RadioButtonGroup 确保一次只选择 1 个按钮.RadioButtonGroup 在
中声明,并且 RadioButtonGroup 的名称在 groupName 属性中分配.
Each group of RadioButtons needs a RadioButtonGroup assigned to the groupName. The RadioButtonGroup makes sure only 1 button is selected at a time.
The RadioButtonGroup is declared in <fx:Declarations>
and is the name of the RadioButtonGroup is assigned in the groupName property.
<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
The Apache Flex reference: http://flex.apache.org/asdoc/spark/components/RadioButtonGroup.html
这篇关于自定义组件中的 RadioButton 功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!