隐藏 Flex 面板中的内容窗格

发布于 2024-09-15 08:51:34 字数 177 浏览 4 评论 0原文

我正在 Flex 3.2 中编写一个自定义组件来扩展面板组件。用户执行特定操作后,我想隐藏面板组件中的主要内容区域,以及控制栏(如果指定)。关于如何做到这一点有什么想法吗? controlBar.visible 似乎没有隐藏控制栏,除了迭代主面板的所有子项之外,我不知道访问主要内容区域的另一种简单方法,如果可能的话,我想避免这种情况。谢谢

I am writing an custom component in Flex 3.2 that extends the panel component. After a user performs a certain action I would like to hide the main content area in the Panel component, as well as the Control Bar if one is specified. Any ideas on how to do this? controlBar.visible does not seem to hide the control bar, and I don't know of another easy way of accessing the main content area besides iterating through all the children of the main panel, and I would like to avoid that if possible. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小…楫夜泊 2024-09-22 08:51:34

您不能在包含所有子项的面板中设置一个主容器(无论是 HBox 还是 VBox 等),然后您可以根据用户的操作切换该容器的可见性。

至于 ControlBar ,您应该能够更改其可见性值......

Couldn't you set one main container, whether a HBox or VBox etc... inside your Panel that would contain all the children, then you could toggle this container visibility depending on the user's action.

As for the ControlBar , you should be able to change its visibility value...

一影成城 2024-09-22 08:51:34

您似乎无法隐藏控制栏的原因是因为您只是设置它的可见属性 - 它仍然占用它的空间。因此,要真正“隐藏”它,请执行以下操作:

myControlBar.includeInLayout = false;

另外,要隐藏所有孩子,只需要一个简单的循环:

for each (var oChild:DisplayObject in idPanel.getChildren()) {
    oChild.visible = false;
}

因此,整个应用程序将如下所示:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:Script>
    <![CDATA[
        private function doit(): void {
            idControl.visible = false;
            idControl.includeInLayout = false;

            for each (var oChild:DisplayObject in idPanel.getChildren()) {
                oChild.visible = false;
            }
        }
    ]]>
</mx:Script>

<mx:Button x="10" y="10" label="Button" click="doit()"/>
<mx:Panel x="83" y="10" width="250" height="200" layout="absolute" id="idPanel">
    <mx:CheckBox x="10" y="10" label="Checkbox"/>
    <mx:DateField x="10" y="40"/>
    <mx:ControlBar id="idControl">
    </mx:ControlBar>
</mx:Panel>

</mx:Application>

希望有帮助!

The reason you can't seem to hide the controlbar, is because you are only setting it's visible property - it's still taking up it's space. So, to truly "hide" it, do this:

myControlBar.includeInLayout = false;

Also, to hide all you children, only requires a simple loop:

for each (var oChild:DisplayObject in idPanel.getChildren()) {
    oChild.visible = false;
}

So, the entire application would look like this:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:Script>
    <![CDATA[
        private function doit(): void {
            idControl.visible = false;
            idControl.includeInLayout = false;

            for each (var oChild:DisplayObject in idPanel.getChildren()) {
                oChild.visible = false;
            }
        }
    ]]>
</mx:Script>

<mx:Button x="10" y="10" label="Button" click="doit()"/>
<mx:Panel x="83" y="10" width="250" height="200" layout="absolute" id="idPanel">
    <mx:CheckBox x="10" y="10" label="Checkbox"/>
    <mx:DateField x="10" y="40"/>
    <mx:ControlBar id="idControl">
    </mx:ControlBar>
</mx:Panel>

</mx:Application>

Hope that helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文