在Flex Alert.show
打开带有CANCEL按钮的对话框后,当我按下ESCAPE键时,它将关闭警告框。但是,如何防止将此关键事件传输到父窗口?父母也可以将ESCAPE注册为关闭密钥,然后它也会关闭。
答案 0 :(得分:0)
Alert.show方法将实例返回给Alert类。你可以在警报上听取逃跑;然后在事件监听器中停止传播。这是伪代码;但是:
// in some method somewhere
// create Alert Class
var myAlert : Alert = Alert.show('test','test');
// listen for keyboard event
myAlert.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
//... elsewhere in code
protected function onKeyUp(event:KeyboardEvent):void{
if(event.charCode =Keyboard.ESCAPE){
event.stopPropagation();
event.stopImmediatePropagation();
}
}