zoukankan      html  css  js  c++  java
  • [Flex] PopUpButton系列 —— 判断下拉列表是否选中

    <?xml version="1.0" encoding="utf-8"?>
    <!--Flex中如何利用dataDescriptor属性和isToggled()函数判断PopUpButton的下拉选项是否选中的例子PopUpButtonSelectableOptions.mxml-->
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
        <fx:Script>
            <![CDATA[
                import mx.controls.Alert;
                import mx.controls.Menu;
                import mx.events.FlexEvent;
                import mx.events.MenuEvent;
                private var _menu:Menu;
                
                protected function popUpButton_initializeHandler(event:FlexEvent):void
                {
                    _menu = new Menu();
                    _menu.variableRowHeight = true;
                    _menu.dataProvider = arr;
                    _menu.addEventListener(MenuEvent.CHANGE,onMenuChange);
                    popUpButton.popUp = _menu;
                }
                
                
                protected function onMenuChange(event:MenuEvent):void
                {
                    switch(_menu.dataDescriptor.getType(event.item)){
                        case "check":
                            if(_menu.dataDescriptor.isToggled(event.item)){
                                this.styleName = "redModal";
                                Alert.show("""+event.item.label+""was checked");
                            }else{
                                Alert.show("""+event.item.label+""was not checked");
                                this.styleName = "greenModal";
                            }
                            break;
                    }
                }
                
            ]]>
        </fx:Script>
        <fx:Declarations>
            <!-- 将非可视元素(例如服务、值对象)放在此处 -->
            <fx:Array id="arr">
                <fx:Object label="Option 1" type="check" toggled="true" />
                <fx:Object label="Option 2" type="check" toggled="true" />
            </fx:Array>
        </fx:Declarations>
        <fx:Style>
            @namespace s "library://ns.adobe.com/flex/spark";
            @namespace mx "library://ns.adobe.com/flex/mx";
            mx|PopUpButton {
                popUpStyleName: MyCustomPopUpStyleName;
            }
            
            .MyCustomPopUpStyleName {
                fontWeight: normal;
                textAlign: left;
            }
            
            .redModal {
                modalTransparencyColor: red;
                modalTransparency: 0.8;
            }
            
            .greenModal {
                modalTransparencyColor: haloGreen;
                modalTransparency: 0.8;
            }
    
        </fx:Style>
        <mx:PopUpButton id="popUpButton" label="Click to open..." openAlways="true" initialize="popUpButton_initializeHandler(event)" />
    </s:Application>
  • 相关阅读:
    微信小程序 checkbox 组件
    微信小程序 button 组件
    h5视频标签 video
    h5离线缓存
    ECharts插件介绍(图表库)
    rich-text 副文本组件 text文本组件
    progress组件(进度条)
    icon组件
    movable-view组件
    android 双击图片变大,缩放功能
  • 原文地址:https://www.cnblogs.com/frost-yen/p/5195434.html
Copyright © 2011-2022 走看看