Fix #32 Ability to copy and paste a URL

This commit is contained in:
Jia Hao 2016-01-25 18:34:44 +08:00
parent d8fb87ccb5
commit 78a624c23f
2 changed files with 12 additions and 2 deletions

View File

@ -56,7 +56,7 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
mainWindow.webContents.send('change-zoom', currentZoom);
};
createMenu(options.nativefierVersion, onAppQuit, mainWindow.webContents.goBack, mainWindow.webContents.goForward, onZoomIn, onZoomOut);
createMenu(options.nativefierVersion, onAppQuit, mainWindow.webContents.goBack, mainWindow.webContents.goForward, onZoomIn, onZoomOut, mainWindow.webContents.getURL);
initContextMenu(mainWindow);
if (options.userAgent) {

View File

@ -1,6 +1,7 @@
var electron = require('electron');
var Menu = electron.Menu;
var shell = electron.shell;
const clipboard = electron.clipboard;
/**
*
@ -10,8 +11,9 @@ var shell = electron.shell;
* @param {electron} onGoForward
* @param {function} onZoomIn
* @param {function} onZoomOut
* @param {function} getUrl
*/
function createMenu(nativefierVersion, onQuit, onGoBack, onGoForward, onZoomIn, onZoomOut) {
function createMenu(nativefierVersion, onQuit, onGoBack, onGoForward, onZoomIn, onZoomOut, getUrl) {
if (Menu.getApplicationMenu()) {
return;
}
@ -43,6 +45,14 @@ function createMenu(nativefierVersion, onQuit, onGoBack, onGoForward, onZoomIn,
accelerator: 'CmdOrCtrl+C',
role: 'copy'
},
{
label: 'Copy Current URL',
accelerator: 'CmdOrCtrl+C',
click: () => {
const currentURL = getUrl();
clipboard.writeText(currentURL);
}
},
{
label: 'Paste',
accelerator: 'CmdOrCtrl+V',