`
阿牛ge
  • 浏览: 104309 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

学习ExtJs(3):Ext.Window在弹出窗口或Msg之后依然可以获得焦点

阅读更多

一个新建的窗口中有一个按钮事件,运行时发现,触发按钮事件弹出窗口(无论是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();

分享到:
评论
2 楼 xljoypark 2012-06-19  
你这的确把第一个窗口隐藏了,但是第二个窗口还在第一个窗口的后面,你这是怎么获取第二个窗口焦点的
1 楼 reason2003 2010-03-12  
只在在win窗口中加入modal:true就可以解决弹出win窗口后后台失去焦点。

相关推荐

Global site tag (gtag.js) - Google Analytics