PDA

View Full Version : How do I prevent a form on a modal window from closing when a user pushes ESC?



twistedsymphony
7 May 2020, 12:39 PM
I have a simple 2-field form in a modal dialog but when a field has focus and the user pushes the ESC key the whole dialog closes. I don't want this to happen. What's weird is it only happens when a field has focus, not when the window has focus.

Here is a fiddle: https://fiddle.sencha.com/#view/editor&fiddle/35rg

Any Help would be appreciated.

twistedsymphony
2 Jul 2020, 8:56 AM
Since no one else replied here I figured I'll post the solution I found.

first if you don't need the full functionalty of a form you can replace a formpanel with a fieldpanel, and it will naturally remove the ENTER and ESC to auto submit and auto cancel

If you're keeping a form however and wish to just remove the ESC shortcut you can add these parameters


keyMapEnabled: false,
keyMap: {
ESC: 'onEscape',
scope: 'this'
},

I placed this on my window and it disabled closing the window on ESC.