如何防止弹出标题窗口后面的项目接收鼠标事件?

发布于 2024-11-30 04:55:21 字数 287 浏览 1 评论 0原文

我有一个 Popup 皮肤 TitleWindow,我将其用作弹出窗口,但其后面的项目正在接收鼠标悬停和单击事件。是否有一个选项可以让我防止 mouseevents 在窗口的主要内容组后面发生?

编辑:澄清一下 - 我不是问如何制作窗口模式。当用户单击 contentGroup 外观部分的区域时,弹出窗口后面的项目(不是在主窗体上,而是在侧面,而是在后面且隐藏)正在接收鼠标事件。如果用户单击该组中的项目,则不会发生这种情况,但轻微的失误可能会触发意外的背景按钮。

I have a Popup skinned TitleWindow that I am using as a popup, but the items behind it are receiving mouse over and click events. Is there an option that lets me prevent mousevents from happening behind the main content group of the window?

EDIT: To clarify - I'm not asking how to make a window modal. Items literally behind the popup - not on the main form but to the side, but behind and hidden - are receiving mouse events when the user clicks on an area of the contentGroup skin part. This doesn't happen if the user clicks on items within that group, but a slight miss might trigger an unexpected background button.

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

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

发布评论

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

评论(5

只是偏爱你 2024-12-07 04:55:21

当您创建弹出设置时modal=true。类似于:

var pop:MyPopUpClass = PopUpManager.createPopUp(parent, MyPopUpClass, true) as MyPopUpClass;

When you create the pop up set modal=true. Something like:

var pop:MyPopUpClass = PopUpManager.createPopUp(parent, MyPopUpClass, true) as MyPopUpClass;

不顾 2024-12-07 04:55:21

您需要将弹出窗口设置为模式窗口。当你制作一些模式时,这意味着窗口(Alert、popup、titleWindow 等)将保留在顶部,屏幕的其余部分将冻结,直到顶部窗口关闭。

“PopUpManager 还提供模式,以便弹出窗口下方的窗口无法接收鼠标事件,并且如果用户在窗口外单击鼠标,还提供一个事件,以便开发人员可以选择关闭窗口或警告用户。”

模态的默认值为false。您可以通过在 addPopupcreatePopup 时传递 true 将其设置为 true

public static function addPopUp(window:IFlexDisplayObject, parent:DisplayObject, modal:Boolean = false, childList:String = null):void 

public static function createPopUp(parent:DisplayObject, className:Classe, modal:Boolean = false, childList:String = null):IFlexDisplayObject 

You need to make your popup window as modal window. when u make something modal, it means that window (Alert, popup, titleWindow etc) will remain at top and rest of the screen freezes till the top window closes.

"The PopUpManager also provides modality, so that windows below the popup cannot receive mouse events, and also provides an event if the user clicks the mouse outside the window so the developer can choose to dismiss the window or warn the user."

Default value of modal is false. you can set it to true by pasing true while addPopup or createPopup

public static function addPopUp(window:IFlexDisplayObject, parent:DisplayObject, modal:Boolean = false, childList:String = null):void 

public static function createPopUp(parent:DisplayObject, className:Classe, modal:Boolean = false, childList:String = null):IFlexDisplayObject 
江挽川 2024-12-07 04:55:21

我通过替换以下内容解决了这个问题:

<s:SparkSkin ...>
<s:Rect height="{hostComponent.height}" radiusX="10" width="{hostComponent.width}">
    <s:fill>
        <s:SolidColor color="#F5F4EB"/>
    </s:fill>
</s:Rect>

<!-- header, move area, close button and other details -->
<s:Group id="contentGroup"
     top="40"
     left="10"
     right="10"
     bottom="10">

</s:Group>
</s:SparkSkin>

用这个:

<s:SparkSkin ...>
<s:Rect height="{hostComponent.height}" radiusX="10" width="{hostComponent.width}">
    <s:fill>
        <s:SolidColor color="#F5F4EB"/>
    </s:fill>
</s:Rect>
<!-- header, move area, close button and other details -->
<s:Group top="40"
     left="10"
     right="10"
     bottom="10">
    <s:Rect top="0"
        left="0"
        right="0"
        bottom="0">
        <s:fill>
            <s:SolidColor color="0xF5F4EB" />
        </s:fill>
    </s:Rect>
    <s:Group id="contentGroup"
             top="0"
             left="0"
             right="0"
             bottom="0">

    </s:Group>
</s:Group>
</s:SparkSkin>

在组后面创建一个矩形对象已使其能够正常接受单击事件。

I solved this by replacing this:

<s:SparkSkin ...>
<s:Rect height="{hostComponent.height}" radiusX="10" width="{hostComponent.width}">
    <s:fill>
        <s:SolidColor color="#F5F4EB"/>
    </s:fill>
</s:Rect>

<!-- header, move area, close button and other details -->
<s:Group id="contentGroup"
     top="40"
     left="10"
     right="10"
     bottom="10">

</s:Group>
</s:SparkSkin>

With this:

<s:SparkSkin ...>
<s:Rect height="{hostComponent.height}" radiusX="10" width="{hostComponent.width}">
    <s:fill>
        <s:SolidColor color="#F5F4EB"/>
    </s:fill>
</s:Rect>
<!-- header, move area, close button and other details -->
<s:Group top="40"
     left="10"
     right="10"
     bottom="10">
    <s:Rect top="0"
        left="0"
        right="0"
        bottom="0">
        <s:fill>
            <s:SolidColor color="0xF5F4EB" />
        </s:fill>
    </s:Rect>
    <s:Group id="contentGroup"
             top="0"
             left="0"
             right="0"
             bottom="0">

    </s:Group>
</s:Group>
</s:SparkSkin>

Creating a rectangle object behind the group has made it so that it accepts click events normally.

森林很绿却致人迷途 2024-12-07 04:55:21

如果您不是在寻找模态答案,那么我所能建议的就是在打开弹出窗口时删除所有相关侦听器,并在删除弹出窗口时将它们添加回来。

x.removeEventListener(MouseEvent.CLICK...
PopUpManager.addPopup(...


onClose(...
x.addEventListener(MouseEvent.CLICK...

If you aren't looking for the modal answer, then all I can recommend is removing all relevant listeners when the popup is opened, and adding them back when the popup is removed.

x.removeEventListener(MouseEvent.CLICK...
PopUpManager.addPopup(...


onClose(...
x.addEventListener(MouseEvent.CLICK...
好菇凉咱不稀罕他 2024-12-07 04:55:21

尝试使用 opaqueBackground 属性。

Try using the opaqueBackground property.

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