加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex中如何利用focusIn和focusOut事件对表单中获得焦点的项目进

发布时间:2020-12-15 03:43:33 所属栏目:百科 来源:网络整理
导读:本文转载自:http://www.51xflash.com/article/flex/201206/09-16499.html 正文内容如下: 接下来的例子演示了Flex中如何利用focusIn和focusOut事件,对表单中获得焦点的项目进行颜色高亮(highlight)显示。 ?xml version="1.0" encoding="utf-8"? mx:Appli

本文转载自:http://www.51xflash.com/article/flex/201206/09-16499.html

正文内容如下:

接下来的例子演示了Flex中如何利用focusIn和focusOut事件,对表单中获得焦点的项目进行颜色高亮(highlight)显示。

<?xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
        layout="vertical" 
        verticalAlign="middle" 
        backgroundColor="white"> 
   
    <mx:Style> 
        FormItem {  
            paddingLeft: 4;  
            paddingRight: 4;  
            paddingTop: 4;  
            paddingBottom: 4;  
        }  
    </mx:Style> 
   
    <mx:Script> 
        <![CDATA[  
            private const BACKGROUND_COLOR:Object = "haloBlue";  
   
            private function formItem_focusIn(evt:FocusEvent):void {  
                var item:FormItem = FormItem(evt.currentTarget.parent);  
                item.setStyle("backgroundAlpha",0.2);  
                item.setStyle("backgroundColor",BACKGROUND_COLOR);  
            }  
   
            private function formItem_focusOut(evt:FocusEvent):void {  
                var item:FormItem = FormItem(evt.currentTarget.parent);  
                item.setStyle("backgroundColor",null);  
            }  
        ]]> 
    </mx:Script> 
   
    <mx:Form> 
        <mx:FormItem label="First name:"> 
            <mx:TextInput id="firstName" 
                    focusIn="formItem_focusIn(event);" 
                    focusOut="formItem_focusOut(event);" /> 
        </mx:FormItem> 
        <mx:FormItem label="Last name:"> 
            <mx:TextInput id="lastName" 
                    focusIn="formItem_focusIn(event);" 
                    focusOut="formItem_focusOut(event);" /> 
        </mx:FormItem> 
    </mx:Form> 
   
</mx:Application> 

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读