Flex:createPopUp ->使除滚动条之外的所有内容均为模态

发布于 2024-12-07 00:22:02 字数 2141 浏览 1 评论 0原文

我制作了这个简单的应用程序来演示我的问题。它有:

  • 一个图像
  • 一个启动弹出窗口的按钮
  • 侧面的滚动条
<mx: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" 
                   verticalScrollPolicy="on"
                   horizontalScrollPolicy="on"
                   layout="vertical">

    <fx:Script>
        <![CDATA[
            import mx.managers.PopUpManager;
            public function buttonClick():void {
                PopUpManager.createPopUp(this,JakePanel,true);
            }
        ]]>
    </fx:Script>

    <mx:Image width="2000"
              source="@Embed(source='assets/image.jpg')"/> 
    <mx:Button click="{buttonClick()}" label="Launch"/>

</mx:Application>

当按下启动按钮时,它会启动这个弹出窗口:

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:fx="http://ns.adobe.com/mxml/2009" 
          xmlns:s="library://ns.adobe.com/flex/spark" 
          xmlns:mx="library://ns.adobe.com/flex/mx" 
          layout="vertical" 
          width="400" height="300"
          title="Popup"
          >
    <fx:Script>
        <![CDATA[
            import mx.managers.PopUpManager;
            public function close():void {
                PopUpManager.removePopUp(this);
            }           
        ]]>
    </fx:Script>
    <s:TextArea text="Enter more text here: " width="100%" height="200"/>
    <s:Button label="OK" click="{close()}" width="100%" height="30" />

</mx:Panel>

这些是我的要求

  1. 当弹出窗口打开时,我需要能够禁用除弹出窗口。为此,我使用:PopUpManager.createPopUp(this,JakePanel,true);。最后一个参数指定弹出窗口是“模式”的,并且它应该捕获所有鼠标事件。

  2. 我还需要允许在弹出窗口打开时启用主滚动条。我的用户通常会在非常小的屏幕中打开应用程序,并且无法调整应用程序的大小。例如:

在此处输入图像描述

当应用程序太小而无法单击“确定”按钮时,就会出现问题:

在此处输入图像描述

有没有办法使除主滚动条之外的所有内容都“模态”?我知道我可以在面板上放置一个滚动条,但我宁愿避免这种情况。

I made this simple application to demonstrate my problem. It has:

  • An image
  • A button that launchess a popup window
  • Scroll bars on the side
<mx: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" 
                   verticalScrollPolicy="on"
                   horizontalScrollPolicy="on"
                   layout="vertical">

    <fx:Script>
        <![CDATA[
            import mx.managers.PopUpManager;
            public function buttonClick():void {
                PopUpManager.createPopUp(this,JakePanel,true);
            }
        ]]>
    </fx:Script>

    <mx:Image width="2000"
              source="@Embed(source='assets/image.jpg')"/> 
    <mx:Button click="{buttonClick()}" label="Launch"/>

</mx:Application>

When the launch button is pressed it launches this popup window:

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:fx="http://ns.adobe.com/mxml/2009" 
          xmlns:s="library://ns.adobe.com/flex/spark" 
          xmlns:mx="library://ns.adobe.com/flex/mx" 
          layout="vertical" 
          width="400" height="300"
          title="Popup"
          >
    <fx:Script>
        <![CDATA[
            import mx.managers.PopUpManager;
            public function close():void {
                PopUpManager.removePopUp(this);
            }           
        ]]>
    </fx:Script>
    <s:TextArea text="Enter more text here: " width="100%" height="200"/>
    <s:Button label="OK" click="{close()}" width="100%" height="30" />

</mx:Panel>

These are my requirements

  1. When the popup is open I need to be able to disable everything except the popup. To do this I am using: PopUpManager.createPopUp(this,JakePanel,true);. The last parameter specifies that the popup is "modal" and that it should capture all mouse events.

  2. I also need to allow the main scroll bars to be enabled while the popup is open. Often my users will have the app open in a very small screen and will not be able to resize the app. For example:

enter image description here

This is a problem when the app is too small to click the ok button:

enter image description here

Is there a way to make everything "modal" except the main scroll bars? I know that I could put a scrollbar on the Panel but I would prefer to avoid this.

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

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

发布评论

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

评论(1

眼前雾蒙蒙 2024-12-14 00:22:02

我认为最好的方法是:

  1. 将主应用程序中的所有内容包装在 标记中。
  2. 当您将 Popup 添加到屏幕调用时:allYourStuff.enabled = false
  3. 当您从屏幕调用中删除 Popup 时:allYourStuff.enabled = true

I think that the best way to do this is to:

  1. Wrap everything in the main application in a <mx:hgroup id="allYourStuff"> tag.
  2. When you add the Popup to the screen call: allYourStuff.enabled = false
  3. When you remove the Popup from the screen call: allYourStuff.enabled = true
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文