1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 00:17:57 +01:00

Add 'Copy' MOW context menu item for Windows users.

This commit is contained in:
Kris Maglione
2010-10-05 00:27:07 -04:00
parent 5946f6a757
commit 1edd4d9ce0
2 changed files with 25 additions and 4 deletions

View File

@@ -149,8 +149,10 @@ const CommandWidgets = Class("CommandWidgets", {
multilineOutput: Class.memoize(function () { multilineOutput: Class.memoize(function () {
let elem = document.getElementById("dactyl-multiline-output"); let elem = document.getElementById("dactyl-multiline-output");
elem.contentDocument.body.id = "dactyl-multiline-output-content"; elem.contentDocument.body.id = "dactyl-multiline-output-content";
document.getElementById("dactyl-context-copylink").style.listStyleImage = ["copy", "copylink", "selectall"].forEach(function (id) {
util.computedStyle(document.getElementById("context-copylink")).listStyleImage; document.getElementById("dactyl-context-" + id).style.listStyleImage =
util.computedStyle(document.getElementById("context-" + id)).listStyleImage;
});
return elem; return elem;
}), }),
multilineInput: Class.memoize(function () document.getElementById("dactyl-multiline-input")), multilineInput: Class.memoize(function () document.getElementById("dactyl-multiline-input")),
@@ -748,6 +750,19 @@ const CommandLine = Module("commandline", {
this.timeout(function () { this.widgets.multilineInput.focus(); }, 10); this.timeout(function () { this.widgets.multilineInput.focus(); }, 10);
}, },
onContext: function onContext(event) {
let enabled = {
link: window.document.popupNode instanceof HTMLAnchorElement,
selection: !window.document.commandDispatcher.focusedWindow.getSelection().isCollapsed
};
for (let [, node] in iter(event.target.childNodes)) {
let group = node.getAttributeNS(NS, "group");
node.hidden = group && !groups.split(/\s+/).some(function (g) enabled[g]);
}
return true;
},
/** /**
* Handles all command-line events. All key events are passed here when * Handles all command-line events. All key events are passed here when
* COMMAND_LINE mode is active, as well as all input, keyup, focus, and * COMMAND_LINE mode is active, as well as all input, keyup, focus, and

View File

@@ -37,10 +37,16 @@
noautohide="true" noautofocus="true"/> noautohide="true" noautofocus="true"/>
<menupopup id="dactyl-contextmenu" <menupopup id="dactyl-contextmenu"
onpopupshowing="return event.target != this || document.popupNode instanceof HTMLAnchorElement;"> onpopupshowing="return (event.target != this || dactyl.modules.commandline.onContext(event));">
<menuitem id="dactyl-context-copylink" <menuitem id="dactyl-context-copylink"
label="Copy Link Location" label="Copy Link Location" dactyl:group="link"
oncommand="goDoCommand('cmd_copyLink');"/> oncommand="goDoCommand('cmd_copyLink');"/>
<menuitem id="dactyl-context-copy"
label="Copy" dactyl:group="selection"
command="cmd_copy"/>
<menuitem id="dactyl-context-selectall"
label="Select All"
command="cmd_selectAll"/>
</menupopup> </menupopup>
</popupset> </popupset>