Add context menu #17
3 changed files with 46 additions and 1 deletions
36
app/menu/context-menu.js
Normal file
36
app/menu/context-menu.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
const {Menu} = require('electron');
|
||||
const electron = require('electron');
|
||||
const app = electron.app;
|
||||
|
||||
const contextMenuTemplate = [
|
||||
{
|
||||
role: 'cut',
|
||||
},
|
||||
{
|
||||
role: 'copy',
|
||||
},
|
||||
{
|
||||
role: 'paste',
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
showContextMenu(win, posX, posY, showDevItems) {
|
||||
let template = contextMenuTemplate.slice();
|
||||
if (showDevItems) {
|
||||
template.push({
|
||||
type: 'separator',
|
||||
});
|
||||
template.push(
|
||||
{
|
||||
label: 'Inspect Element',
|
||||
click() {
|
||||
win.inspectElement(posX, posY);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Menu.buildFromTemplate(template).popup(win);
|
||||
},
|
||||
};
|
|
@ -21,7 +21,7 @@ var drawerImageStyle = { //@TODO: remove this, img should be properly scaled onc
|
|||
|
||||
var Drawer = React.createClass({
|
||||
handleLogoClicked: function(event) {
|
||||
if (event.ctrlKey && event.shiftKey) {
|
||||
if ((event.ctrlKey || event.metaKey) && event.shiftKey) {
|
||||
window.location.href = 'index.html?developer'
|
||||
event.preventDefault();
|
||||
}
|
||||
|
|
|
@ -5,8 +5,17 @@ import lighthouse from './lighthouse.js';
|
|||
import App from './app.js';
|
||||
import SplashScreen from './component/splash.js';
|
||||
|
||||
const {remote} = require('electron');
|
||||
const contextMenu = remote.require('./menu/context-menu');
|
||||
|
||||
lbry.showMenuIfNeeded();
|
||||
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
contextMenu.showContextMenu(remote.getCurrentWindow(), event.x, event.y,
|
||||
lbry.getClientSetting('showDeveloperMenu'));
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
var init = function() {
|
||||
window.lbry = lbry;
|
||||
window.lighthouse = lighthouse;
|
||||
|
|
Loading…
Reference in a new issue