简体   繁体   English

extjs 关闭 ESC 上的 Ext.window.Window

[英]extjs closing a Ext.window.Window on ESC

I'm working on extjs4.我正在研究 extjs4。 I have a grid panel.我有一个网格面板。 on selecting a row of the grid panel, I create a simple window.在选择网格面板的一行时,我创建了一个简单的 window。 I would like to close it when the user hits ESC.我想在用户点击 ESC 时关闭它。 If the user clicks anything in the window and then clicks ESC, the window is closed.如果用户单击 window 中的任何内容,然后单击 ESC,则 window 将关闭。 But if the user didn't touched the window yet, ESC would not close the window.但是如果用户还没有触摸 window,ESC 不会关闭 window。 Any idea how to do that?知道怎么做吗?

var win = Ext.create('Ext.window.Window', {
                    title: 'Details',
                    width: 400,
                        layout: 'fit',
                        iconCls: 'details-icon',
                        items: simple
                    }).show();

maybe it's no foucus at win.也许这不是胜利的焦点。

or try to use this:或尝试使用这个:

listen to window show event, and add a KeyMap to document:监听 window 显示事件,并在文档中添加一个 KeyMap:

 var map = new Ext.util.KeyMap(Ext.getBody(), [{
    key: Ext.EventObject.ESC,
    defaultEventAction: 'preventDefault',
    scope: this,
    fn: function(){win.close()}
 }]);

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

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