| 103 | } |
| 104 | |
| 105 | function initContextMenu() { |
| 106 | menu = new Menu(); |
| 107 | menu.append(new MenuItem({ |
| 108 | label: 'Copy', |
| 109 | click: function() { |
| 110 | clipboard.writeText(editor.getSelection(), 'copy'); |
| 111 | } |
| 112 | })); |
| 113 | menu.append(new MenuItem({ |
| 114 | label: 'Cut', |
| 115 | click: function() { |
| 116 | clipboard.writeText(editor.getSelection(), 'copy'); |
| 117 | editor.replaceSelection(''); |
| 118 | } |
| 119 | })); |
| 120 | menu.append(new MenuItem({ |
| 121 | label: 'Paste', |
| 122 | click: function() { |
| 123 | editor.replaceSelection(clipboard.readText('copy')); |
| 124 | } |
| 125 | })); |
| 126 | |
| 127 | window.addEventListener('contextmenu', function(ev) { |
| 128 | ev.preventDefault(); |
| 129 | menu.popup(remote.getCurrentWindow(), ev.x, ev.y); |
| 130 | }, false); |
| 131 | } |
| 132 | |
| 133 | |
| 134 | onload = function() { |