Fix right click bug

This commit is contained in:
Igor Gassmann 2018-01-05 19:25:33 -03:00
parent b3fb847912
commit 60772d0a74
3 changed files with 7 additions and 20 deletions

View file

@ -10,9 +10,9 @@ import ChildProcess from 'child_process';
import Assert from 'assert'; import Assert from 'assert';
import { app, BrowserWindow, globalShortcut, ipcMain, Menu, Tray } from 'electron'; import { app, BrowserWindow, globalShortcut, ipcMain, Menu, Tray } from 'electron';
import mainMenu from './menu/mainMenu'; import mainMenu from './menu/mainMenu';
import contextMenu from './menu/contextMenu';
const localVersion = app.getVersion(); const localVersion = app.getVersion();
export { contextMenu as Default } from './menu/contextMenu';
// Debug configs // Debug configs
const isDevelopment = process.env.NODE_ENV === 'development'; const isDevelopment = process.env.NODE_ENV === 'development';
@ -526,3 +526,5 @@ ipcMain.on('get-auth-token', event => {
ipcMain.on('set-auth-token', (event, token) => { ipcMain.on('set-auth-token', (event, token) => {
Keytar.setPassword('LBRY', 'auth_token', token ? token.toString().trim() : null); Keytar.setPassword('LBRY', 'auth_token', token ? token.toString().trim() : null);
}); });
export { contextMenu };

View file

@ -1,18 +1,8 @@
import { Menu } from 'electron'; import { Menu } from 'electron';
const contextMenuTemplate = [ const contextMenuTemplate = [{ role: 'cut' }, { role: 'copy' }, { role: 'paste' }];
{
role: 'cut',
},
{
role: 'copy',
},
{
role: 'paste',
},
];
export default function contextMenu(win, posX, posY, showDevItems) { export default (win, posX, posY, showDevItems) => {
const template = contextMenuTemplate.slice(); const template = contextMenuTemplate.slice();
if (showDevItems) { if (showDevItems) {
template.push({ template.push({
@ -27,4 +17,4 @@ export default function contextMenu(win, posX, posY, showDevItems) {
} }
Menu.buildFromTemplate(template).popup(win); Menu.buildFromTemplate(template).popup(win);
} };

View file

@ -20,12 +20,7 @@ import app from './app';
const { contextMenu } = remote.require('./main.js'); const { contextMenu } = remote.require('./main.js');
window.addEventListener('contextmenu', event => { window.addEventListener('contextmenu', event => {
contextMenu.showContextMenu( contextMenu(remote.getCurrentWindow(), event.x, event.y, app.env === 'development');
remote.getCurrentWindow(),
event.x,
event.y,
app.env === 'development'
);
event.preventDefault(); event.preventDefault();
}); });