Skip to content

Commit 058371a

Browse files
committed
Show/hide window when clicking on tray
1 parent 430687f commit 058371a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ app.on("activate", () => {
166166
app.on("ready", () => {
167167
setApplicationMenu();
168168
mainWindow = createMainWindow();
169-
setUpTray(app, mainWindow);
169+
const tray = setUpTray(app, mainWindow);
170+
tray.on("click", () => {
171+
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
172+
});
170173

171174
if (!is.dev() && autoUpdate()) {
172175
autoUpdater.checkForUpdatesAndNotify();

tray.js

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module.exports.setUpTray = (app, win) => {
2222
});
2323
tray = new Tray(trayIcon);
2424
tray.setToolTip("Youtube Music");
25+
tray.setIgnoreDoubleClickEvents(true);
2526

2627
const trayMenu = Menu.buildFromTemplate([
2728
{
@@ -66,4 +67,6 @@ module.exports.setUpTray = (app, win) => {
6667
},
6768
]);
6869
tray.setContextMenu(trayMenu);
70+
71+
return tray;
6972
};

0 commit comments

Comments
 (0)