Bug 1198339 - Bind F1 key to open the settings when the toolbox is focused;r=jryans

This commit is contained in:
Brian Grinstead 2015-09-01 09:34:41 -07:00
parent 2e7c07c221
commit aca0a738f8
4 changed files with 20 additions and 9 deletions

View File

@ -50,11 +50,15 @@ function* testSelectTool() {
function* testOptionsShortcut() {
info ("Selecting another tool, then reselecting options panel with keyboard.");
yield toolbox.selectTool("webconsole")
.then(() => synthesizeKeyFromKeyTag("toolbox-options-key", doc))
.then(() => {
ok(true, "Toolbox selected via shortcut key");
});
yield toolbox.selectTool("webconsole");
is(toolbox.currentToolId, "webconsole", "webconsole is selected");
synthesizeKeyFromKeyTag("toolbox-options-key", doc);
is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (1)");
yield toolbox.selectTool("webconsole");
is(toolbox.currentToolId, "webconsole", "webconsole is selected");
synthesizeKeyFromKeyTag("toolbox-options-key2", doc);
is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (2)");
}
function* testOptions() {

View File

@ -457,10 +457,11 @@ Toolbox.prototype = {
},
_buildOptions: function() {
let selectOptions = () => { this.selectTool("options"); };
let key = this.doc.getElementById("toolbox-options-key");
key.addEventListener("command", () => {
this.selectTool("options");
}, true);
key.addEventListener("command", selectOptions, true);
let key2 = this.doc.getElementById("toolbox-options-key2");
key2.addEventListener("command", selectOptions, true);
},
_splitConsoleOnKeypress: function(e) {

View File

@ -9,9 +9,11 @@
<!DOCTYPE window [
<!ENTITY % toolboxDTD SYSTEM "chrome://browser/locale/devtools/toolbox.dtd" >
%toolboxDTD;
%toolboxDTD;
<!ENTITY % editMenuStrings SYSTEM "chrome://global/locale/editMenuOverlay.dtd">
%editMenuStrings;
<!ENTITY % globalKeysDTD SYSTEM "chrome://global/locale/globalKeys.dtd">
%globalKeysDTD;
]>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
@ -30,6 +32,9 @@
key="&toolboxOptionsButton.key;"
oncommand="void(0);"
modifiers="shift, accel"/>
<key id="toolbox-options-key2"
keycode="&openHelp.commandkey;"
oncommand="void(0);"/>
<key id="toolbox-next-tool-key"
key="&toolboxNextTool.key;"
oncommand="void(0);"

View File

@ -955,6 +955,7 @@ PropertyView.prototype = {
let keyEvent = Ci.nsIDOMKeyEvent;
if (event.keyCode === keyEvent.DOM_VK_F1) {
this.mdnLinkClick();
event.preventDefault();
}
if (event.keyCode === keyEvent.DOM_VK_RETURN ||
event.keyCode === keyEvent.DOM_VK_SPACE) {