简体   繁体   中英

extjs closing a Ext.window.Window on ESC

I'm working on extjs4. I have a grid panel. on selecting a row of the grid panel, I create a simple window. I would like to close it when the user hits ESC. If the user clicks anything in the window and then clicks ESC, the window is closed. But if the user didn't touched the window yet, ESC would not close the 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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