繁体   English   中英

Flex:记住SuperTabNavigator的PopUpButton上的选项卡索引和名称

[英]Flex: Remember the tab index and name on the PopUpButton of the SuperTabNavigator

众所周知,SuperTabNavigator是flexLib的一个开源组件,它比Flex Tab Navigator更具优势,我们可以使用SuperTabNavigator从每个选项卡上的关闭按钮关闭这些选项卡。 另外,选项卡导航器的右侧有一个按钮,显示了一次打开的所有选项卡的列表,我们可以从该按钮中选择任何选项卡,即PopupButton。 现在发生的是,当我们关闭选项卡时,它也从PopupButton下拉列表中消失了。 但就我而言,我希望下拉菜单甚至记住关闭的选项卡,以便当我单击该关闭的选项卡时,它在选项卡导航器中再次打开。 我对Flex和ActionScipt相对较新,非常感谢所有经验丰富的编码人员提供的帮助,教程或提示。 我保证我会在网上为其他Flex编码人员很好地记录下来。 :)

提前致谢。

好的,我以前没有使用过超级选项卡导航器,但是在建立一个跟踪所有已关闭选项卡的项目时遇到了麻烦,并为用户提供了以后根据需要重新打开它们的选项。

我无法弄清楚如何使小的下拉菜单记住关闭的标签,而又不影响实际的标签可见。 因此,作为变通办法,这是一个使用Flex SDK 3.6的小型简单应用程序,希望您发现它有用,它应该按原样运行...

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" minWidth="955" minHeight="600" xmlns:ns="http://code.google.com/p/flexlib/">
    <mx:VBox>
        <ns:SuperTabNavigator id="navigator"
                              width="500"
                              height="500"
                              tabClose="recordClosedTab(event)"
                              creationComplete="init()">
            <mx:Canvas label="one"/>
            <mx:Canvas label="two"/>
            <mx:Canvas label="three"/>
        </ns:SuperTabNavigator>
        <mx:HBox>
            <mx:Label text="Closed tabs:"/>
            <mx:ComboBox id="closedTabsMenu"
                         close="closedTabsMenuCloseHandler(event)"/>
        </mx:HBox>
    </mx:VBox>

    <mx:Script>
        <![CDATA[
            import flexlib.events.SuperTabEvent;

            import mx.collections.ArrayCollection;
            import mx.containers.Canvas;
            import mx.events.DropdownEvent;

            private var _closedTabs:ArrayCollection = new ArrayCollection();

            /**
             * Records which display object has been removed from the SupreTabNavigator.
             * Updates closed tabs menu data provider.
             * 
             * @param SuperTabEvent.TAB_CLOSE dispatched from SuperTabNavigator when a tab close button is clicked.
             * */
            private function recordClosedTab(event:SuperTabEvent):void{
                _closedTabs.addItem(navigator.getChildAt(event.tabIndex) as DisplayObject);
                closedTabsMenu.dataProvider = _closedTabs;
            }

            /**
             * Handles the close event dispatched from combo box on close.
             * Checks if the SuperTabNavigator contains the item currently selected in combo box.
             * If not then adds that object if it is a DisplayObject
             * Then removes that item from combo box.
             * 
             * @param DropdownEvent.CLOSE dispatched from the ComboBox on close
             * */
            private function closedTabsMenuCloseHandler(event:DropdownEvent):void{
                var tabs:ArrayCollection = new ArrayCollection(navigator.getChildren());
                if (!tabs.contains(closedTabsMenu.selectedItem)){
                    if (closedTabsMenu.selectedItem is DisplayObject){
                        navigator.addChild(closedTabsMenu.selectedItem as DisplayObject);
                        _closedTabs.removeItemAt(_closedTabs.getItemIndex(closedTabsMenu.selectedItem));
                    }
                }
            }

        ]]>
    </mx:Script>
</mx:Application>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM