一个新建的窗口中有一个按钮事件,运行时发现,触发按钮事件弹出窗口(无论是Msg.confirm之类的消息,还是Msg.show),后台窗口还是可以获得焦点。
这样用户可以绕过弹出窗口,继续操作后面的窗口,包括所有的事件。搜索了一下,需要手动调用第一个窗口的disable()和enable()事件。这两个事件是从Ext.Component继承下来的.
直接看代码,注意黑体部分。
var win=new Ext.Window({title:"窗口"+i++,
width:400,
height:400,
maximizable:true,
manager:mygroup,
items:[new Ext.Panel({
title:"面板头部header",
width:200,
height:300,
html:'<h1>面板主区域</h1>',
tools:[{id:"save"},
{id:"help",handler:function(){Ext.Msg.alert('help','please help me!');}},
{id:"close",handler:function(){lpnel.hide();}}],
tbar:[{pressed:true,text:'刷新'},{text:'顶部工具栏topToolbar'}],
bbar:[{text:'底部工具栏bottomToolbar'}],
buttons:[{text:"按钮位于footer"},
{text:"Submit",handler:function(){
//Ext.Msg.confirm("系统提示", "你是否确定删除此记录", this.onRemovePerson, this);
//win.setActive(false); //没有必要,只要设置disable就可以了
win.disable();
Ext.Msg.show({
title:'Do this Action?',
modal:true,
msg: 'Would you like to do this action?',
buttons: Ext.Msg.YESNO,
fn: function(btn){
if(btn == 'yes'){
//dothisaction();
}
else{//not to do
};
// win.setActive(true);
win.enable();
},
icon: Ext.MessageBox.QUESTION
});
}}]
})]
});
win.show();