Bug 1128175 - add explicit <esc> handler, r=jaws

This commit is contained in:
Gijs Kruitbosch 2015-03-12 10:25:20 +00:00
parent 96372c9131
commit a8dd24ef2d

View File

@ -222,6 +222,11 @@ let gSubDialog = {
},
_onKeyDown: function(aEvent) {
if (aEvent.currentTarget == window && aEvent.keyCode == aEvent.DOM_VK_ESCAPE &&
!aEvent.defaultPrevented) {
this.close(aEvent);
return;
}
if (aEvent.keyCode != aEvent.DOM_VK_TAB ||
aEvent.ctrlKey || aEvent.altKey || aEvent.metaKey) {
return;
@ -278,6 +283,10 @@ let gSubDialog = {
this._frame.addEventListener("load", this);
chromeBrowser.addEventListener("unload", this, true);
// Ensure we get <esc> keypresses even if nothing in the subdialog is focusable
// (happens on OS X when only text inputs and lists are focusable, and
// the subdialog only has checkboxes/radiobuttons/buttons)
window.addEventListener("keydown", this, true);
},
_removeDialogEventListeners: function() {
@ -290,6 +299,7 @@ let gSubDialog = {
window.removeEventListener("DOMFrameContentLoaded", this, true);
this._frame.removeEventListener("load", this);
this._frame.contentWindow.removeEventListener("dialogclosing", this);
window.removeEventListener("keydown", this, true);
this._untrapFocus();
},