Skip to content

Commit de16376

Browse files
committed
enabled empty tray icon
(fixes click event on macos)
1 parent 8f92d39 commit de16376

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

ElectronNET.API/Tray.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ public void Show(string image, MenuItem[] menuItems)
263263
});
264264
}
265265

266+
/// <summary>
267+
/// Shows the Traybar (empty).
268+
/// </summary>
269+
/// <param name="image">The image.</param>
270+
public void Show(string image)
271+
{
272+
BridgeConnector.Socket.Emit("create-tray", image);
273+
}
274+
266275
/// <summary>
267276
/// Destroys the tray icon immediately.
268277
/// </summary>

ElectronNET.Host/api/tray.js

Lines changed: 9 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/tray.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,18 @@ export = (socket: SocketIO.Socket) => {
5353
});
5454

5555
socket.on('create-tray', (image, menuItems) => {
56-
const menu = Menu.buildFromTemplate(menuItems);
57-
58-
addMenuItemClickConnector(menu.items, (id) => {
59-
electronSocket.emit('trayMenuItemClicked', id);
60-
});
61-
6256
const trayIcon = nativeImage.createFromPath(image);
6357

6458
tray = new Tray(trayIcon);
65-
tray.setContextMenu(menu);
59+
60+
if (menuItems) {
61+
const menu = Menu.buildFromTemplate(menuItems);
62+
63+
addMenuItemClickConnector(menu.items, (id) => {
64+
electronSocket.emit('trayMenuItemClicked', id);
65+
});
66+
tray.setContextMenu(menu);
67+
}
6668
});
6769

6870
socket.on('tray-destroy', () => {

0 commit comments

Comments
 (0)