【问题标题】:get selected tabbed panel in the flex在 flex 中获取选定的选项卡式面板
【发布时间】:2012-03-06 09:49:26
【问题描述】:

我在 flex 中有一个选项卡式面板,其中包含各种选项卡,我使用它来获取选定的选项卡索引

private function handleInspectorAreaButtonClick(e:Event):void
        {
            var selectedIndex:int;

            switch(Button(e.target))
            {
                case propertiesButton:
                    selectedIndex = 0;
                    break;

                case dimensionsButton:
                    selectedIndex = 1;
                    break;

                case footnotesButton:
                    selectedIndex = 2;
                    break;

                case calculationsButton:
                    selectedIndex = 3;
                    break;

                case whereUsedButton:
                    selectedIndex = 4;
                    break;
            }

            inspectorAreaViewStack.selectedIndex = selectedIndex;
        }

但问题是我没有获得选定的选项卡式索引值 m 为 NULL,因此未选择选项卡这是 m 选择的面板

    <s:HGroup id="inspectorAreaViewStackControls" width="100%" paddingTop="8" paddingLeft="4" paddingRight="4">
        <s:Button id="property" label="Properties" click="handleInspectorAreaButtonClick(event)"/>
        <s:Button id="distance" label="Dimensions" click="handleInspectorAreaButtonClick(event)"/>

    </s:HGroup>

这是我要更改的视图堆栈

<mx:ViewStack id="inspectorAreaViewStack" width="100%" height="100%" paddingTop="8" paddingLeft="4" paddingRight="4" selectedIndex="0" backgroundColor="0xFFFFFF">

            <s:NavigatorContent width="100%" label="propertiesContent">
                <tagInspectorAspects:PropertiesAspect id="propertiesAspect"/>
            </s:NavigatorContent>

            <s:NavigatorContent width="100%" label="dimensionsContent">
                <tagInspectorAspects:DimensionsAspect/>
                    </mx:ViewStack>

【问题讨论】:

  • 你能发布完整的代码吗?以及在 switch case 用例属性中:而不是 case propertiesButton:
  • @rajesh.adhi 我编辑了代码,这就是我所拥有的
  • Librak,你找到了哪个解决方案?

标签: apache-flex flex4


【解决方案1】:
<s:HGroup id="inspectorAreaViewStackControls" width="100%" paddingTop="8" paddingLeft="4" paddingRight="4">
        <s:Button id="property" label="Properties" click="handleInspectorAreaButtonClick(event)"/>
        <s:Button id="distance" label="Dim" click="handleInspectorAreaButtonClick(event)"/>
</s:HGroup>


private function handleInspectorAreaButtonClick(e:Event):void
        {
            var selectedIndex:int;

            switch(e.currentTarget.id)
            {
                case 'property':
                    selectedIndex = 0;
                    break;

                case 'distance':
                    selectedIndex = 1;
                    break;
            }

            inspectorAreaViewStack.selectedIndex = selectedIndex;
        }

【讨论】:

    【解决方案2】:

    您可以使用以下特定语句

    { event.currentTarget.selectedIndex;

    } 事件必须是鼠标事件。

    【讨论】:

      猜你喜欢
      • 2011-11-28
      • 1970-01-01
      • 2018-07-25
      • 2023-03-22
      • 1970-01-01
      • 2011-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多