How to prevent window closing on ESC extjs 4

I am stuck with one problem with one problem in order to stop closing a window using the ESC button.

The window closes as soon as I press the ESC button from the keyboard. I want the window not to close, instead it should call up a window asking "DO YOU REALLY WANT to close" with two buttons, yes or cancel

If a person clicked the "Yes" button, the window should be destroyed, and the window should be as it is.

but I don’t know why the window is approaching pressing ESC.

I request a message when the user clicks the esc button using the code below

listeners: { show : function(win) { Ext.create('Ext.util.KeyNav', win.getEl(), { "esc" : function(e){ alert('hi.. closing'); win.hide(); }, scope: win }); } } 

Now I want the message box to appear based on the person’s response to the things that are about to happen. any help?

+7
source share
2 answers

There is a very convenient onEsc function in window config. Use it as follows:

 onEsc: function() { var me = this; Ext.Msg.confirm( 'Closing confirmation', 'YOU REALLY WANTS TO close', function(btn) { if (btn === 'yes') me.hide(); } ); }, 

Here is a living example .

+10
source

Try using the beforeclose event.

+3
source

All Articles