简体   繁体   English

Adobe Flex弹出窗口

[英]adobe flex popup

I need to close the popup(adobe flex), non modal window if I click on the parent page of the popup. 如果单击弹出窗口的父页面,则需要关闭弹出窗口(adobe flex)非模式窗口。 I have to do the out of focus check and then do some validation before close the popup. 我必须先进行焦点模糊检查,然后在关闭弹出窗口之前进行一些验证。 So what I was thinking that is there any inbuilt focus check event or do we need to create custom event for that ? 那么我在想什么有内置的焦点检查事件,或者我们需要为此创建自定义事件吗?

In your popup you need to listen for mouse up event on the popup itself, and the stage. 在弹出窗口中,您需要侦听弹出窗口本身和舞台上的鼠标向上事件。 On the popup if you catch a mouse up event, stop it from getting to the stage. 如果您在弹出窗口中捕获到鼠标上移事件,请使其停止进入舞台。 Then, if you receive a mouse up event on the stage you will know that it was outside of the popup and can close the popup. 然后,如果您在舞台上收到一个鼠标悬停事件,您将知道它不在弹出窗口之外,并且可以关闭弹出窗口。

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" creationComplete="onCreationComplete()">
    <mx:Script>
        <![CDATA[
            import mx.managers.PopUpManager;

            private function onCreationComplete():void {
                //listen for MouseUp events on the popup, and the stage
                this.addEventListener(MouseEvent.MOUSE_UP, handleMouseUp);
                stage.addEventListener(MouseEvent.MOUSE_UP, handleStageMouseUp);
            }

            private function handleMouseUp(e:MouseEvent):void {
                //catch any MouseUp events on the popup, 
                //and prevent them from getting to the stage
                e.stopPropagation(); //don't let this event get to the stage
            }

            private function handleStageMouseUp(e:MouseEvent):void {
                //if the stage fires a MouseUp event, the mouse event 
                //came from outside of the popup, so we can close it
                closePopup();
            }

            private function validate():Boolean {
                //add your validate code here
                return true;
            }

            private function closePopup():void {
                if ( validate() ) {
                    //clean up event listeners, and close popup
                    stage.removeEventListener(MouseEvent.MOUSE_UP, handleStageMouseUp);
                    PopUpManager.removePopUp(this);
                }
            }
        ]]>
    </mx:Script>
</mx:Canvas>

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

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