Skip to content

Instantly share code, notes, and snippets.

@jojobyte
Forked from b1rdex/main.js
Created Dec 6, 2013
Embed
What would you like to do?
$(function(
function Menu(cutLabel, copyLabel, pasteLabel) {
var gui = require('nw.gui')
, menu = new gui.Menu()
, cut = new gui.MenuItem({
label: cutLabel || "Cut"
, click: function() {
document.execCommand("cut");
console.log('Menu:', 'cutted to clipboard');
}
})
, copy = new gui.MenuItem({
label: copyLabel || "Copy"
, click: function() {
document.execCommand("copy");
console.log('Menu:', 'copied to clipboard');
}
})
, paste = new gui.MenuItem({
label: pasteLabel || "Paste"
, click: function() {
document.execCommand("paste");
console.log('Menu:', 'pasted to textarea');
}
})
;
menu.append(cut);
menu.append(copy);
menu.append(paste);
return menu;
}
var menu = new Menu(/* pass cut, copy, paste labels if you need i18n*/);
$(document).on("contextmenu", function(e) {
e.preventDefault();
menu.popup(e.originalEvent.x, e.originalEvent.y);
});
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment