disable escape key in dijit.Dialog / dojo dialog

Dojo likes to trap events, as such the current way to disable the escape key for dialogs is to use dojo.stopEvent(evt) …

 

   1:  dojo.connect(dijit.byId("disclaimer_dialog").containerNode, 'onkeypress', function(evt) {
   2:              key = evt.keyCode;
   3:              if (key == dojo.keys.ESCAPE) {
   4:                  console.debug("Escape trapped !!")
   5:                  dojo.stopEvent(evt);
   6:              }
   7:          });

 

I’m starting to feel like there is “the dojo way” and them um…expected way…

Maybe I just missed it but why isn’t there a property for “disableEscape” or “allowEscape” …whatever…it works right…

No related posts.

Thursday, September 4th, 2008 Dojo

2 Comments to disable escape key in dijit.Dialog / dojo dialog

  1. Hi Eric, thank you so much, I almost eat my hat with the escape key. To copy your code I had to view the page source code because it doesn’t appears very well on browser.

  2. Alonso on November 6th, 2008
  3. good way!

  4. learner on June 11th, 2009

Leave a comment

Search