From ec33a63b4d4287bde3271b2508c78a3a8f247683 Mon Sep 17 00:00:00 2001 From: Julien Maille Date: Thu, 12 Feb 2026 18:19:34 +0100 Subject: [PATCH] NEW: close to tray --- neutralino.config.dev.json | 2 +- neutralino.config.json | 2 +- public/neutralino_loader.html | 40 ++++++++++++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/neutralino.config.dev.json b/neutralino.config.dev.json index 65b45f7..87606da 100644 --- a/neutralino.config.dev.json +++ b/neutralino.config.dev.json @@ -26,7 +26,7 @@ "borderless": false, "enableInspector": true, "openInspectorOnStartup": true, - "exitProcessOnClose": true + "exitProcessOnClose": false } }, "port": 5050, diff --git a/neutralino.config.json b/neutralino.config.json index 078e74c..2d99a0e 100644 --- a/neutralino.config.json +++ b/neutralino.config.json @@ -26,7 +26,7 @@ "borderless": false, "enableInspector": true, "openInspectorOnStartup": false, - "exitProcessOnClose": true + "exitProcessOnClose": false } }, "port": 5050, diff --git a/public/neutralino_loader.html b/public/neutralino_loader.html index 954d5ae..74bdc4a 100644 --- a/public/neutralino_loader.html +++ b/public/neutralino_loader.html @@ -36,6 +36,42 @@ try { Neutralino.init(); console.log('[Shell] Neutralino initialized.'); + + const setupTray = async () => { + const iconPath = '/dist/assets/appicon.png'; + console.log('[Shell] Setting tray icon:', iconPath); + const tray = { + icon: iconPath, + menuItems: [ + { id: 'show', text: 'Show Monochrome' }, + { id: 'sep', text: '-' }, + { id: 'quit', text: 'Quit' } + ] + }; + try { + await Neutralino.os.setTray(tray); + console.log('[Shell] Tray set successfully'); + } catch(e) { + console.error('[Shell] Tray error:', e); + await Neutralino.os.showMessageBox('Tray Error', `Failed to set tray: ${JSON.stringify(e)}`, 'ERROR'); + } + }; + + Neutralino.events.on('ready', setupTray); + + Neutralino.events.on('trayMenuItemClicked', async (event) => { + switch (event.detail.id) { + case 'show': + await Neutralino.window.show(); + await Neutralino.window.unminimize(); + await Neutralino.window.focus(); + break; + case 'quit': + await Neutralino.app.exit(); + break; + } + }); + } catch (e) { console.error('[Shell] Failed to init Neutralino:', e); } @@ -90,7 +126,9 @@ // Listen for specific events to forward // Add more here if the app needs them (e.g., tray events) - Neutralino.events.on('windowClose', () => forwardEvent('windowClose')); + Neutralino.events.on('windowClose', async () => { + await Neutralino.window.hide(); + }); Neutralino.events.on('windowFocus', () => forwardEvent('windowFocus')); Neutralino.events.on('windowBlur', () => forwardEvent('windowBlur'));