Skip to content

Commit

Permalink
Show/hide window when clicking on tray
Browse files Browse the repository at this point in the history
  • Loading branch information
th-ch committed Apr 26, 2020
1 parent 430687f commit 058371a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ app.on("activate", () => {
app.on("ready", () => {
setApplicationMenu();
mainWindow = createMainWindow();
setUpTray(app, mainWindow);
const tray = setUpTray(app, mainWindow);
tray.on("click", () => {
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
});

if (!is.dev() && autoUpdate()) {
autoUpdater.checkForUpdatesAndNotify();
Expand Down
3 changes: 3 additions & 0 deletions tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports.setUpTray = (app, win) => {
});
tray = new Tray(trayIcon);
tray.setToolTip("Youtube Music");
tray.setIgnoreDoubleClickEvents(true);

const trayMenu = Menu.buildFromTemplate([
{
Expand Down Expand Up @@ -66,4 +67,6 @@ module.exports.setUpTray = (app, win) => {
},
]);
tray.setContextMenu(trayMenu);

return tray;
};

0 comments on commit 058371a

Please sign in to comment.