Reputation: 364
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();
Upvotes: 1
Views: 8776
Reputation: 4256
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()}
}]);
Upvotes: 3