1
如果我点击弹出窗口的父页面,我需要关闭弹出窗口(adobe flex),非模态窗口。我必须做焦点检查,然后在关闭弹出窗口之前做一些验证。那么我在想那是否有任何内置的重点检查事件,或者我们是否需要为此创建自定义事件?adobe flex弹出
如果我点击弹出窗口的父页面,我需要关闭弹出窗口(adobe flex),非模态窗口。我必须做焦点检查,然后在关闭弹出窗口之前做一些验证。那么我在想那是否有任何内置的重点检查事件,或者我们是否需要为此创建自定义事件?adobe flex弹出
在弹出窗口中,您需要监听弹出窗口本身和舞台上的鼠标弹起事件。在弹出的对话框中,如果发现鼠标事件,请停止它进入舞台。然后,如果您在舞台上收到鼠标上移事件,您将知道它位于弹出窗口之外,并可以关闭弹出窗口。
<?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>
+1的意见:) – weltraumpirat
所以这似乎是令人费解的方式..我想你也可以只添加为mouseDownOutside =“handleMouseDownOutside(事件)”,以您的弹出... –