extjs closing a Ext.window.Window on ESC
I'm working on ex开发者_如何学Ctjs4. 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()}
}]);
精彩评论