Skip to content

Commit

Permalink
Add a context menu on the app icon on right click for Windows (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
amitmerchant1990 authored and Mike Schultz committed Oct 20, 2016
1 parent f9dc6dc commit 6dd6838
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const electron = require('electron');
const menubar = require('menubar')({
width: 370,
height: 410,
Expand All @@ -7,12 +8,44 @@ const menubar = require('menubar')({
tooltip: "Materialette",
resizable: false
});

const contextMenu = electron.Menu.buildFromTemplate([
{
label: 'About',
click() {
electron.dialog.showMessageBox({title: "Materialette", type:"info", message: "Material Color Palette for macOS, Windows, and Linux", buttons: ["Close"] });
}
},
{
label: 'Website',
click() {
electron.shell.openExternal("https://github.com/mike-schultz/materialette");
}
},
{
type: 'separator'
},
{
label: 'Quit',
click() {
menubar.app.quit();
}
}

]);

menubar.on('ready', ()=>{
global.sharedObj = {
hide: menubar.hideWindow,
quit: menubar.app.quit,
pinned: false
}

// This will add a context menu on the
// app icon on right click for Windows
if (process.platform == 'win32') {
menubar.tray.setContextMenu(contextMenu);
}
});

menubar.on('focus-lost', () => {
Expand Down

0 comments on commit 6dd6838

Please # to comment.