Skip to content
This repository was archived by the owner on Sep 2, 2023. It is now read-only.

Commit

Permalink
[TASK] Cut / Copy / Paste context menu (DC-50)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mesrop committed Aug 25, 2015
1 parent 521c020 commit 480c9a4
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/js/controllers/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,46 @@ module.controller('AppCtrl', ['$rootScope', '$compile', 'rpId', 'rpNetwork',
return isIssuer;
};


/**
* Context menu
*/
var Menu = function(cutLabel, copyLabel, pasteLabel) {
var gui = require('nw.gui'),
menu = new gui.Menu(),
cut = new gui.MenuItem({
label: cutLabel || "Cut",
click: function() {
document.execCommand("cut");
}
}),
copy = new gui.MenuItem({
label: copyLabel || "Copy",
click: function() {
document.execCommand("copy");
}
}),
paste = new gui.MenuItem({
label: pasteLabel || "Paste",
click: function() {
document.execCommand("paste");
}
});

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();
e.target.tagName == 'INPUT' && menu.popup(e.originalEvent.x, e.originalEvent.y);
});


/**
* Testing hooks
*/
Expand Down

0 comments on commit 480c9a4

Please sign in to comment.