I have am using dijit/popup to display a dialog widget when a button is clicked. The documentation below describes how to use dijit/popup to control the popup.
https://dojotoolkit.org/reference-guide/1.10/dijit/popup.html
The code is as follows:
define(["dijit/popup"], function(popup){
...
// wrap the pop-up widget and position it offscreen so
// that it can be measured by the widget’s startup method
popup.moveOffScreen(dropDown);
// if the pop-up has not been started yet, start it now
if(dropDown.startup && !dropDown._started){
dropDown.startup();
}
// make the pop-up appear around my node
popup.open({
parent: this,
popup: dropDown,
around: this.domNode,
orient: ["below-centered", "above-centered"],
onExecute: function(){
popup.close(dropDown);
},
onCancel: function(){
popup.close(dropDown);
},
onClose: function(){
}
});
...
However the default behavior of dijit/popup is to call the onCancel callback function either when the popped up widget signals its cancelled or when the ESC key is pressed:
https://dojotoolkit.org/reference-guide/1.10/dijit/popup.html#keyboard-handling
I can see this happening when the ESCape key is pressed however I don't want the dialog to be closed for ESC (or TAB) key press - how can I achieve this? How can I detect when the onCancel callback is executed as a result of the user pressing the Escape key?
Alternatively how can I prevent dijit/popup calling onCancel only when the escape key is pressed?