自定义组件中的RadioButton功能 [英] RadioButton functionality in custom component

查看:105
本文介绍了自定义组件中的RadioButton功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个包含图像和单选按钮的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?

谢谢

推荐答案

每组RadioButtons需要一个分配给groupName的RadioButtonGroup. RadioButtonGroup确保一次仅选择1个按钮. 在<fx:Declarations>中声明了RadioButtonGroup,它是在groupName属性中分配的RadioButtonGroup的名称.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆