summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@codeispoetry.ru>2017-03-20 16:50:08 +0000
committerAndrej Mihajlov <and@codeispoetry.ru>2017-03-20 16:50:08 +0000
commitdffc82249c4b80792e4f21f6cdbb80048f93d7a2 (patch)
tree45f6b628d087abfce78f5ca43a26f6101b478d52
parent8fd8accfa18436ff2367ff020cab0b5279c1ce38 (diff)
downloadmullvadvpn-dffc82249c4b80792e4f21f6cdbb80048f93d7a2.tar.xz
mullvadvpn-dffc82249c4b80792e4f21f6cdbb80048f93d7a2.zip
Fix copy/paste support
Adds context menu on all editable fields
-rw-r--r--app/main.js55
1 files changed, 43 insertions, 12 deletions
diff --git a/app/main.js b/app/main.js
index 2534cfa089..e1e2fd0b1a 100644
--- a/app/main.js
+++ b/app/main.js
@@ -61,7 +61,7 @@ const installExtensions = async () => {
const installDevTools = async () => {
await installExtensions();
- // show devtools when ctrl clicked
+ // show devtools when ctrl clicked
tray.on('click', function () {
if(!window) { return; }
@@ -75,17 +75,6 @@ const installDevTools = async () => {
window.openDevTools({ mode: 'detach' });
}
});
-
- // add inspect element on right click menu
- window.webContents.on('context-menu', (e, props) => {
- Menu.buildFromTemplate([{
- label: 'Inspect element',
- click() {
- window.openDevTools({ mode: 'detach' });
- window.inspectElement(props.x, props.y);
- }
- }]).popup(window);
- });
};
const getWindowPosition = () => {
@@ -136,7 +125,48 @@ const createWindow = () => {
window.on('hide', () => {
stopTrayEventMonitor();
});
+};
+
+const createContextMenu = () => {
+ let menuTemplate = [
+ // Undo/redo has to be fixed in AccountInput
+ // {role: 'undo'},
+ // {role: 'redo'},
+ // {type: 'separator'},
+
+ {role: 'cut'},
+ {role: 'copy'},
+ {role: 'paste'},
+ {type: 'separator'},
+ {role: 'selectall'}
+ ];
+ // add inspect element on right click menu
+ window.webContents.on('context-menu', (e, props) => {
+ let inspectTemplate = [{
+ label: 'Inspect element',
+ click() {
+ window.openDevTools({ mode: 'detach' });
+ window.inspectElement(props.x, props.y);
+ }
+ }];
+
+ if(props.isEditable) {
+ let inputMenu = menuTemplate;
+
+ // mixin "inspect element" into standard menu
+ // when in development mode
+ if(isDevelopment) {
+ inputMenu = menuTemplate.concat([{type: 'separator'}], inspectTemplate);
+ }
+
+ Menu.buildFromTemplate(inputMenu).popup(window);
+ } else if(isDevelopment) {
+ // display inspect element for all non-editable
+ // elements when in development mode
+ Menu.buildFromTemplate(inspectTemplate).popup(window);
+ }
+ });
};
const toggleWindow = () => {
@@ -176,6 +206,7 @@ app.on('window-all-closed', () => {
app.on('ready', () => {
createTray();
createWindow();
+ createContextMenu();
if(isDevelopment) {
installDevTools();